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

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

Asked by
VitroxVox 884 Moderation Voter
4 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by
yHasteeD 1819 Moderation Voter
4 years ago
Edited 4 years ago

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 :)

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. VitroxVox 884 — 4y
Ad

Answer this question