Place teleport system not working after first time

Hello! I am trying to create a system that lets you join a game when a timer has ended.

The issue is that when the game tries to teleport people for the second time, it does not end up teleporting them. This does work the first time, and the second time it all works until it tries to teleport people.

local joined = game.Workspace.Data.Touched -- The part that they touch to queue up
local TeleportService = game:GetService('TeleportService')
local players = game:GetService('Players')
local GameId = -- Removed in the example
local Timer = game.Workspace.Room.TimerWall.SurfaceGui.TextLabel
local Players = game.Workspace.Data.InGame -- IntValue that tracks how many people are in the queue
local Teleporting = {}
local Count = 60

local function Teleport()
	for _, touched in pairs(joined:GetChildren()) do
		if touched:IsA('BoolValue') then
			if touched.Value == true then
				table.insert(Teleporting, players:FindFirstChild(touched.Name)) -- Adds to the teleporting table the player that is marked as being able to teleport.
			end
		end
	end
	-- When the table has all the players, the game will teleport every player in the table.
	
	TeleportService:TeleportAsync(GameId, Teleporting)
	Players.Value = 0
end

while true do
	wait(1)
	if Count > 0 and Players.Value > 1 then
		Count -= 1
		Timer.Text = tostring(Players.Value)..'/24   '..Count..' Seconds left'
	else
		if Players.Value > 1 then
			Timer.Text = 'Teleporting...'
			Teleport()
			wait(15)
			Count = 60
		else
			Count = 60
			Timer.Text = 'The round will not start until there are 2+ players.'
		end
	end
end

Sorry if my code is bad, I am still a beginner.

1 Like

Do you get any errors?

1 Like

I can’t really test it that well because I need to test in-game but the dev console doesn’t show anything.

1 Like

You receive error because you don’t empty:

local Teleporting = {}

Your place trying teleport ALL players, even if they ALREADY got teleported, and DON’T exist in the server.

2 Likes