Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Teleporting to ReserveServer problem?

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)




1 answer

Hi dude, I think it's because you did not put the parentheses and stuff properly, that's why and there's some errors in the script as well. Also, I don't recommend using too much spacing as this will make the script run slower.

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local code = TeleportService:ReserveServer(4822839179)
local players = {}

RemoteEvent.OnServerEvent:Connect(function(player)
	for i, v in pairs(Players:GetPlayers()) do
		if player:WaitForChild("PlayerGui").In.Value == true then
			table.insert(players,v)
			print(v)
		end
	end
end)

TeleportService:TeleportToPrivateServer(4822839179, code, players)

4 comments

0

Oh I forgot to put that in I got it from a remote event RemoteEvent.OnServerEvent:Connect(function(player, X)

0

Oo can accept the answer if this helps? Thanks :)

0

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.

0

@JiveMaster i've changed the code based on what you said

This discussion is preserved as it was. New answers, comments, and votes are closed.