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?
01 | local remote = game.ReplicatedStorage.StartEvent |
02 | remote.OnServerEvent:Connect( function (player) |
03 | for i, v in pairs (game.Players:GetPlayers()) do |
04 | local bool = v:FindFirstChildOfClass( "BoolValue" ) |
05 | local frame = v.PlayerGui.ActiveLobbys.Frame.Frame.Frame |
06 | local player 2 = frame.PlayerName.Text |
07 | local gameplaceid = 3313994275 |
08 | local Player = player |
09 | local PlayersToTeleport = { } |
10 | local AlreadyInTable = false |
11 |
12 | for _,OtherPlayer in next ,PlayersToTeleport do |
13 | if OtherPlayer = = Player then |
14 | AlreadyInTable = true |
15 | end |
Here this should help:
1 | local TeleportService = game:GetService( "TeleportService" ) |
2 | local Reserve = TeleportService:ReserveServer( 3313994275 ) |
3 | for i,v in pairs (game.Players:GetChildren()) do |
4 | table.insert(PlayerToTeleport,i,v.Name) |
5 | end |
6 | for i,v in pairs (PlayersToTeleport) do |
7 | TeleportService:TeleportToPrivateServer(gameplaceid, Reserve, PlayerToTeleport [ v ] ) |
8 | 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.