I want to make lobby system by myself. It works pretty well, but the issue is. Whenever i get ReserveServer. It still giving me the error “HTTP 403 (Forbidden)” .
Here’s all line of codes:
-- change settings here
local maxplayers = 2
local maxtimer = 20
local placeID = 17267036049
-- other variables
local list = {}
local playerExistsInLobby = false
local teleportProcessing = false
local timer
local frame = script.Parent.SurfaceGui.Frame
local enterpart = script.Parent.Parent.waitingpoint
local cablecar_basepart = script.Parent.Parent.CableCar.Base
local replicatedstorage = game:GetService("ReplicatedStorage")
local teleportservice = game:GetService("TeleportService")
local teleportOptions = Instance.new("TeleportOptions")
local function updateplayer ()
frame.PlayerNum.Text = #list .. "/" .. maxplayers
end
-- start values
frame.PlayerNum.Text = #list .. "/" .. maxplayers
-- running values
replicatedstorage.LeaveGuiEvent.OnServerEvent:Connect(function (player)
for i = 1, #list do
if list[i] == player.Character.Name then
player.Character.Humanoid.Jump = true
task.wait(.1)
player.Character.HumanoidRootPart.CFrame = script.Parent.Parent.ExitLobbyPart.CFrame
table.remove(list, i)
if #list < 0 then
playerExistsInLobby = false
teleportProcessing = false
end
updateplayer()
end
end
end)
-- when touches a wall
script.Parent.Touched:Connect(function (hit)
if hit.Parent:FindFirstChild("Humanoid") then
if teleportProcessing == false then
local char = hit.Parent
local players = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
local playerenter = false
-- do things here and check the teleport process or max players
for i = 1, #list do
if list[i] == char.Name then
playerenter = true
end
end
if playerenter == false then
if #list < maxplayers then
table.insert(list, char.Name)
char:FindFirstChild("HumanoidRootPart").CFrame = enterpart.CFrame
updateplayer()
print(list)
replicatedstorage.LeaveGuiEvent:FireClient(players, true)
for i = 1, #list do
if #list >= 1 then
if list[i] == char.Name then
playerExistsInLobby = true
end
else
playerExistsInLobby = false
end
end
end
-- check if player left then remove character name from the table
game:GetService("Players").PlayerRemoving:Connect(function (plrWhoGetsRemovedOrLeft)
if plrWhoGetsRemovedOrLeft.Name == char.Name then
for i = 1, #list do
if list[i] == plrWhoGetsRemovedOrLeft.Name then
table.remove(list, i)
updateplayer()
print(#list , list[1] , list[2])
if teleportProcessing == true then
if #list <= 0 then
teleportProcessing = false
end
end
end
end
end
end)
-- check if player die or removed then remove character name from the table
players.CharacterRemoving:Connect(function (charWhoGetsRemovedOrDied)
if charWhoGetsRemovedOrDied.Name == char.Name then
for i = 1, #list do
if list[i] == charWhoGetsRemovedOrDied.Name then
table.remove(list, i)
updateplayer()
print(#list , list[1] , list[2])
if teleportProcessing == true then
if #list <= 0 then
teleportProcessing = false
end
end
end
end
end
end)
end
end
end
end)
while task.wait() do
for i = 1, maxtimer do
timer = maxtimer - i
frame.Timer.Text = timer
task.wait(1)
end
if #list > 0 then
if playerExistsInLobby == true then
teleportProcessing = true
frame.Status.Text = "Teleporting"
for i = 1, #list do
if list[i] then
local player = game:GetService("Players"):FindFirstChild(list[i])
-- runs when player is exist and being teleported
replicatedstorage.LeaveGuiEvent:FireClient(player, false)
task.wait(5)
teleportservice:TeleportToPrivateServer(placeID,teleportservice:ReserveServer(placeID), player)
task.wait(5)
teleportProcessing = false
end
end
repeat task.wait() until not teleportProcessing
frame.Status.Text = "Ready"
playerExistsInLobby = false
for i = 1, #list do
if list[i] then
table.remove(list, i)
updateplayer()
end
end
end
end
end
Here’s the short line of code of the issues.
for i = 1, #list do
if list[i] then
local player = game:GetService("Players"):FindFirstChild(list[i])
-- runs when player is exist and being teleported
replicatedstorage.LeaveGuiEvent:FireClient(player, false)
task.wait(5)
teleportservice:TeleportToPrivateServer(placeID,teleportservice:ReserveServer(placeID), player)
task.wait(5)
teleportProcessing = false
end
end
I’ve tried using TeleportOptions and get the Reserve Server. Which didn’t work aswell.