My teleporting script is suppose to teleport everyone, but it's only teleporting the player who clicked. Not sure why its doing this, is there an error?
local remote = game.ReplicatedStorage.StartEvent remote.OnServerEvent:Connect(function(player) for i, v in pairs(game.Players:GetPlayers()) do local bool = v:FindFirstChildOfClass("BoolValue") local frame = v.PlayerGui.ActiveLobbys.Frame.Frame.Frame local player2 = frame.PlayerName.Text local gameplaceid = 3313994275 local Player = player local PlayersToTeleport = {} local AlreadyInTable = false for _,OtherPlayer in next,PlayersToTeleport do if OtherPlayer == Player then AlreadyInTable = true end end if not AlreadyInTable then table.insert(PlayersToTeleport,Player) end local TeleportService = game:GetService("TeleportService") local Reserve = TeleportService:ReserveServer(3313994275) TeleportService:TeleportToPrivateServer(gameplaceid, Reserve, PlayersToTeleport) end end)
Here this should help:
local TeleportService = game:GetService("TeleportService") local Reserve = TeleportService:ReserveServer(3313994275) for i,v in pairs(game.Players:GetChildren()) do table.insert(PlayerToTeleport,i,v.Name) end for i,v in pairs(PlayersToTeleport) do TeleportService:TeleportToPrivateServer(gameplaceid, Reserve, PlayerToTeleport[v]) end
You should've called the TeleportService and the Reserve variables at the start of the script to avoid changing lines etc. What I did here is that I looked how much player's there where, and teleported each player 1 by 1 in a for i,v loop.