Why does it keep repeating the function?

I have 2 functions that i put in a “while true do” loop so they can infinitely make a round based system. However i ran into the problem where after RoundCountdown() it would play again and again.

All Help is appreciated

Here are the lines:

local function RoundCountdown()
	local timeleft
	
	if #Players:GetChildren() <= 1 then
		InfoLabel.Text = "Waiting for more players..."
		task.wait(2.5)
		RoundCountdown()
	end

	for i = 12, 0, -1 do
		InfoLabel.Text = "Intermission.."..i	
		task.wait(1)
	end
	
	for i,v in pairs(Players:GetChildren()) do
		table.insert(PlayersInRound, v)
		v.Character:MoveTo(workspace["The Park"].MapSpawn.Position)
		IsInMatch:FireClient(v, true)
	end

	for i = 5, 0, -1 do
		InfoLabel.Text = "Round Starting in "..i.."."
		task.wait(1)
	end

end

More Lines down:

coroutine.resume(coroutine.create(function()
	while true do
		RoundCountdown()
		StartRound()
		task.wait()
	end
end))

You Are telling it repeat, Just halt the code instead of doing this:

1 Like

1.)How would I halt it?
2.)
That’s only if there are 1 or less players in the game, I tested it with 2 players

Something like this:

repeat 
InfoLabel.Text = "Waiting for more players..."
task.wait(1)
until #Players:GetPlayers() > 1
2 Likes