How would I teleport all players in an array?

I am almost finished with making my queue system and the only problem I have is teleporting the players. An example would be:

_G.Queue = {Player1, Player2}

Since the players in the queue are from different servers how would I teleport them all to a game using TeleportService?
My only approach was looping through the table but it only teleports 1 person. Any solutions?

4 Likes

what did you do?
You got to loop through

1 Like

This is what I mean

_G.Queue = {Player1, Player2}

if #_G.Queue == 2 then
	for _, plr in ipairs(_G.Queue) do
		TeleportService:Teleport(GameId, game.Players[plr])
	end
end

It only teleports the first person who joined the Queue

1 Like
for i = 1,#_G.Queue do
    coroutine.wrap(function() 
      TeleportService:Teleport(GameId, game:GetService("Players"):FindFirstChild(_G.Queue[i])) 
    end)() 
end

Also try to print the array.

1 Like

Check this out, it’s not 100% safe, but it can work very well:
https://developer.roblox.com/en-us/api-reference/function/TeleportService/TeleportPartyAsync