Round system not working

local IntermissionTime = 5
local InRound = game.ReplicatedStorage.InRound
local status = game.ReplicatedStorage.Status

InRound.Changed:Connect(function()
	if InRound == true then
		for _,plr in pairs(game.Players:GetChildren()) do
			plr.Character.Parent = game.Workspace.PlayingInRound
			plr.Character.CFrame = game.Workspace.RoundArea.RoundSpawn.CFrame
		end
	else
		for _,plr in pairs(game.Players:GetChildren()) do
			plr.Character.Parent = game.Workspace.Spectating
			plr.Character.CFrame = game.Workspace.SpectateArea.SpecSpawn.CFrame
		end
	end
end)

local function RoundStarter()
	while wait() do
		for i = IntermissionTime, 0, -1 do
			InRound = false
			wait(1)
			status.Value = "Intermission: "..i.." seconds left"
		end
		for i, v in pairs(game.Players:GetChildren()) do
			InRound = true
			wait()
		end
	end
end

spawn(RoundStarter)

i think the problem is with the while wait() true thing but i am not too sure.

also dont ask about the second for loop in the function idk why i put it like that

basically, the point of the game is that everyone will get a gun and after the round starts the last person standing is the winner, i havent gotten to that part because of this error.

local IntermissionTime = 5
local InRound = game.ReplicatedStorage.InRound
local status = game.ReplicatedStorage.Status
local roundEnded = true

InRound.Changed:Connect(function()
	if InRound == true then
		for _,plr in pairs(game.Players:GetChildren()) do
			plr.Character.Parent = game.Workspace.PlayingInRound
			plr.Character.CFrame = game.Workspace.RoundArea.RoundSpawn.CFrame
		end
	else
		for _,plr in pairs(game.Players:GetChildren()) do
			plr.Character.Parent = game.Workspace.Spectating
			plr.Character.CFrame = game.Workspace.SpectateArea.SpecSpawn.CFrame
		end
	end
end)

local function RoundStarter()
	roundEnded = false
	for i = IntermissionTime, 0, -1 do
		InRound = false
		wait(1)
		status.Value = "Intermission: "..i.." seconds left"
	end
	for i, v in pairs(game.Players:GetChildren()) do
		InRound = true
		wait()
	end
	roundEnded = true
end

while task.wait() do
	if roundEnded then
		task.spawn(RoundStarter)
	end
end

Just have a boolean track when the round ends and then if it has ended start a new one.

The issue before was the nested loops without any condition checking, so for every wait() a new for loop would begin.

i am gonna try this, thanks for your help :heart: