My for loop isn't inserting players in to a table. I tried using tables but it doesn't work. Here's the part where the problem is:
local players = {}
wait(5)
for _, a in pairs(game.ReplicatedStorage.Players:GetChildren()) do
table.insert(players, game.Players[a.Name])
end
local code = game:GetService("TeleportService"):ReserveServer(9800587169)
game:GetService("TeleportService"):TeleportToPrivateServer(9800587169, code, players)
Hello,
You do not need a table what you can do is loop through Players directly. This will be obtained like:
local Players = game.Players -- Reference to your players local code = game:GetService("TeleportService"):ReserveServer(9800587169) -- Private server function TpAll() for _, Player in pairs(Players:GetPlayers) do -- Loop through players TS:TeleportToPrivateServer(9800587169,code,Player) -- Tp Player end end TpAll() wait(5) if #Players > 0 then -- Recheck in case of failed Tp TpAll() end
More on TeleportService
More on Loops
More on Tables
I Hope this Helps