Timer Issue Script

I’m once again asking for your scripting support

I’m making a Lobby where when there is more than one player the counter starts until zero, then it will teleport the players to the game.

The issue: When more players join the queue the timer start to go from -1/sec to -2/-3/sec making the timer count like 10 seconds.

Here is the script i’m using

local function cancel()
	script.Parent.Time.Value = 30
end

Started = false

script.Parent.Players.Changed:Connect(function()
	if script.Parent.Players.Value >= 1 then
		
			Started = true
		if Started == true then
			repeat
			script.Parent.Time.Value = script.Parent.Time.Value -1
            Started = false
			wait(1)
			until script.Parent.Players.Value < 1 or script.Parent.Time.Value <= 0
		end
		
        local tp = game:GetService("TeleportService")
		local server = tp:ReserveServer(5496511414)
		for i,v in pairs(script.Parent.Waiting:GetChildren()) do
			if game.Players:FindFirstChild(v.Name) then
				
				local Players = game:GetService("Players")

				print("For now working...")
				local plr = Players:FindFirstChild(v.Name)
				print(plr)
				print("Teleport ", plr, "To ", server )

				
				tp:TeleportToPrivateServer(5496511414, server, {plr})
				
				
				v:Destroy()
			end
		end
		cancel()
	else
	cancel()
end
end)
1 Like

This line will always trigger, I assume its a debounce but implemented where would not have that function

if script.Parent.Players.Value >= 1 then
	Started = true
if Started == true then
--change to
if script.Parent.Players.Value >= 1 then

if Started == false then 
Started = true

Tested, when a second player joins the queue the script fires the entire script and teleport them all without timer