Hi, I want to teleport all players that have a value in there playergui set to true, but It works it just teleports each player in the group to there own server, I only want to teleport a group of players to there own server and let no one else join. I've never done teleporting before so I need a little help.
Code:
local TeleportService = game:GetService"TeleportService"
local Players = game:GetService"Players"
local code = TeleportService:ReserveServer(4822839179)
local players = {}
for i, v in pairs(Players:GetPlayers()) do
if game.Players[player.Name].PlayerGui.In.Value == true then
table.insert(players,v)
print(v)
end
TeleportService:TeleportToPrivateServer(4822839179,code,players)

4 comments
Oh I forgot to put that in I got it from a remote event RemoteEvent.OnServerEvent:Connect(function(player, X)
Oo can accept the answer if this helps? Thanks :)
You shouldn't use game.Players[player.Name] if you already have a reference to the player. Just use the player variable to access the player. Also, the server shouldn't be accessing a PlayerGui. It's not a special instance for replication from the client to the server; client changes in the PlayerGui won't replicate.
@JiveMaster i've changed the code based on what you said