Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to teleport group of players to the same game server?

Asked by
mricky 0
8 years ago

I have a system where people can get into groups/parties with other users in their lobby and I want to know if there is any possible way I could send them to the same server using the teleportation system for games.

Example: greg, derek, sarah, and molly are all in a part together, The party leader would then press start and all of them will be teleported to the same server. How would i go about teleporting them?

2 answers

Log in to vote
0
Answered by
sad_eyez 162
8 years ago

the only way I could think of is like this:

for i,x in pairs(game.Players:GetChildren()) do
if x.Name == "Whatever" then
-- [[ CODE HERE ]] --
end
end

or

local groupofplayers = --Where ever your group is located
for i,x in pairs(game.Players:GetChildren()) do
if x.Name == groupofplayers.Name  then
-- [[ CODE HERE ]] --
end
end

somethine like that, I'm sorry if it's not to helpful, I'm not the best at explaining stuff

0
I know how to itterate through the players. I need to know if there is a way to make it so they all get sent to the same server, not just the same place. mricky 0 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")

local code = TS:ReserveServer(game.PlaceId) -- Returns a code
local players = Players:GetPlayers() -- Get a list of all players

TS:TeleportToPrivateServer(game.PlaceId,code,players) -- Actually teleport the players
-- You could add extra arguments to this function: spawnName, teleportData and customLoadingScreen

Copied directly from the wiki.

Answer this question