Basically I have a round system script where it uses a for loop to check if the players are still alive. But for some reason. it completely skips the if #amtOfChildren <= 0 then Part and just completely breaks.
for i = 300,0, -1 do
status.Value = "Game: "
status2.Value = i
task.wait(1)
if #amtOfChildren <= 0 then
break
end
end
Basically I have a round system that loops every second and counts down 300 seconds.
There is a folder in workspace that has all the players when a round in progress. And in the loop. It checks the amount of children in folder I mentioned earlier. It uses break to end the round
local amtOfChildren = game:GetService("Workspace"):WaitForChild("playersinround")
for i = 300,0, -1 do
status.Value = "Game: "
status2.Value = i
task.wait(1)
if #amtOfChildren:GetChildren() <= 0 then
break
end
end
I assume it may be related to the fact you fetch the children once, so the #amtOfChildren value stays constant and doesn’t update. Instead, fetch the children within the loop:
for i = 300,0, -1 do
local amtOfChildren = game:GetService("Workspace"):WaitForChild("playersinround")
status.Value = "Game: "
status2.Value = i
task.wait(1)
if #amtOfChildren:GetChildren() <= 0 then
break
end
end