This script teleports players to a reserved server but it only worked the first time I made it. I didn’t make any changes to it but it isn’t working anymore. The players never teleport and I don’t get any errors.
for i,v in pairs(game.Players:GetPlayers()) do
if v.Character then
if game.Workspace.Teams.Queue:FindFirstChild(v.Name) then
spawn(function()
TeleportService:TeleportToPrivateServer(6369483613, accessCode, {v})
connection = TeleportService.TeleportInitFailed:Connect(function(player, teleportResult, errorMessage)
print("Teleport failed, TeleportResult: "..teleportResult.Name)
if teleportResult == Enum.TeleportResult.Failiure or teleportResult == Enum.TeleportResult.Flooded then
connection:Disconnect()
delay(0.25, function()
print("Reattempting teleport")
TeleportService:TeleportToPrivateServer(6369483613, accessCode, {v})
end)
end
end)
end)
end
end
end
Maybe I’m missing something but I can’t see you setting a value to “accessCode”.
Before teleporting the players you should set it’s value to a reserved server of the placeId (in this case 6369483613)
So like this:
local accessCode = TeleportService:ReserveServer(6369483613)
for i,v in pairs(game.Players:GetPlayers()) do
if v.Character then
if game.Workspace.Teams.Queue:FindFirstChild(v.Name) then
spawn(function()
TeleportService:TeleportToPrivateServer(6369483613, accessCode, {v})
connection = TeleportService.TeleportInitFailed:Connect(function(player, teleportResult, errorMessage)
print("Teleport failed, TeleportResult: "..teleportResult.Name)
if teleportResult == Enum.TeleportResult.Failiure or teleportResult == Enum.TeleportResult.Flooded then
connection:Disconnect()
delay(0.25, function()
print("Reattempting teleport")
TeleportService:TeleportToPrivateServer(6369483613, accessCode, {v})
end)
end
end)
end)
end
end
end
You first have to reserve a server if you are teleporting multiple players. This reserved server is stored as your “accessCode”. Yours was still empty.
Hope this helped! Please let me know if it didn’t!