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

How do i teleport a table of players?

Asked by 3 years ago

i have this script that creates a timer when one or more players enter the lobby, once the timer is finished it will teleport the players to a game, but i want it to teleport all the players to the same server, and it seems like it teleports each player to a separate server instead.

01while wait() do
02    if numofplayers.Value > 0 then
03        repeat
04            if numofplayers.Value > 0 then
05                wait(1)
06                timer.Value = timer.Value-1
07            end
08        until timer.Value == 0
09        wait(2)
10        print("Teleporting players")
11        if #playerstotp > 0 then
12            for i,v in pairs(playerstotp) do
13                tpservice:Teleport(placeid, v)
14                table.remove(playerstotp, i)
15                print(#playerstotp)
View all 32 lines...

2 answers

Log in to vote
3
Answered by 3 years ago

You can use the TeleportAsync function instead, which is like the Teleport function but with the support for multiple players, with the player(s) argument being a table, instead of an object.

It's also a yielding function which means that it pauses the thread until it finishes executing (IE: teleporting all players), this seems quite useful in your case as you want to wait for all players to teleport.

1
Ok i worked i just had to change teleportasync to teleportpartyasync GameBuilderLol 58 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

So should it look something like this?

1tpservice:TeleportAsync(placeid, playerstotp)

Answer this question