Teleport Service Question :TeleportToPrivateServer

Heya! Quick question.
When we give an array to :TeleportToPrivateServer TP service. It holds the array even if we delete all entries in it after that? Cause the next line after the TP, occurs inmediately no matter if the Teleport Service finished its job or not.
Example:

local TPS = game:GetService("TeleportService")
local Place = 15648643516

-- Table previously filled with players to teleport
local TP_Array = {player1, player2, etc} -- Lets say 30 players

local function TP()
	local ID = TPS:ReserveServer(Place)
	TPS:TeleportToPrivateServer(Place, ID, TP_Array) -- This will take a few seconds to teleport all players in the array
	--If I flush the TP_Array, the Teleport function still knows all entries in table???
	TP_Array = {} -- Flushing the table. This line occurs inmediately even if the Teleport Service didnt finish with teleporting all the players
end
1 Like

What I would do is get the amount of players and put them in a loop such as;
Then I would Check to see if the list of players has teleported and wait

local function TP()
	local ID = TPS:ReserveServer(Place)
	TPS:TeleportToPrivateServer(Place, ID, TP_Array) -- This will take a few seconds to teleport all players in the array
	spawn(function()
	for i,v in ipairs(TP_Array) do 
		if i == #TP_Array then
			print("Flush")
			TP_Array = {} -- Flushing the table. This line occurs inmediately even if the Teleport Service didnt finish with teleporting all the players
		end
	 	v.OnTeleport:Wait()
		end
	end)
end
1 Like