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

How do i teleport a squad/group/ a group of users to a private server in a game?

Ye so i need help with teleporting a group of users to a private reserved server because it didn't work for me i've tried and i'm giving up, i need a little help boys here's my source:

function teleport()

local playerList = {}
local TS = game:GetService("TeleportService") 
	
	local code = TS:ReserveServer(c)
	
	local curcode = code

	for _,g in pairs(script.playersonplat:GetDescendants()) do
		 
		TS:TeleportToPrivateServer(c,curcode,game.Players[g.Name])
	
	end
	
		
	curcode = nil

end

^^ The placeid of the place is not there on purpose

1 answer

✓ Accepted answer

You need to send a table of all players, basically this:

local Players = {game.Players.Player1, game.Players.Player2}
TS:TeleportToPrivateServer(..., ..., Players)

For your code, try to find the player... and tem add it do a table

local TS = game:GetService("TeleportService") 
local PlaceId = ...

function Teleport()
	local playerList = {}
	local Server = TS:ReserveServer(PlaceId)
	
	--> I don't know what's inside this folder, so I tried to do it this way:
	for _, Player in pairs(script.playersonplat:GetDescendants()) do
		if game.Players:FindFirstChild(Player.Name) then
			table.insert(playerList, game.Players[Player.Name]) --> Add the player to the list
		end
	end

	TS:TeleportToPrivateServer(PlaceId, Server, playerList) --> Teleport all players
end

Teleport()

Hope it helped :)

1 comment

0

You did it right cause there's an boolvalue with the users name in the folder, i'll try then if it works i'll accept.

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