don’t place that inside that, just leave that part as
for i = roundLength, 0, -1 do
InRound.Value = true
if won.Value == true then
break
end
wait(1)
status.Value = "Game: ".. i .." seconds left!"
if #runnersTable < 1 then break end
end
it should work precisely like that because when all users die and the game timer is still running it will realize that the runnersTable is < 1 and will break
repeat
wait()
runners = #game.Players:GetPlayers();
until runners < 1 or won.Value == true
Inside of this:
for i = roundLength, 0, -1 do
InRound.Value = true
if won.Value == true then
break
end
wait(1)
status.Value = "Game: ".. i .." seconds left!"
end
It didn’t work. Intermission clock would always stay at zero.
@greatneil80 Ok it now tells me runnersTable is an unknown variable blah blah, what would I set it as? I deleted it earlier, but now I want to hear you say what it should be.
No, replace the for loop and remove the spawn(function()) and try this instead:
local runners = #game.Players:GetPlayers();
local roundlength = (Your length)
repeat
runners = #game.Players:GetPlayers();
roundlength = roundlength - 1;
status.Value = "Game: ".. roundlength.." seconds left!"
wait(1)
until runners < 1 or won.Value == true or roundlength <= 0
if (runners < 1) then
-- Do something
elseif (won.Value == true then)
-- Do something
end
If that doesn’t fix your issue, it’s not a synchronizing issue. Check what game.Players:GetPlayers() is returning with a print(#game.Players:GetPlayers()) and check the won.Value with a print(won.Value) inside of the repeat function.
Edit: I forgot to add the roundlength <= 0 check to break the until loop as well.
I restored my original script, and all I changed was the original for loop to this:
for i = roundLength, 0, -1 do
InRound.Value = true
if won.Value == true then
break
end
wait(1)
status.Value = "Game: ".. i .." seconds left!"
if #runnersTable < 1 then break end
end
And I think I made a little advancement! It would count down intermission, but when it reached game time it would teleport the players to the game area for a tiny fraction of a second and go back to intermission spawn and restart intermission time. What now?
Edit: When the loop breaks, it’s supposed to go back to intermission time. Maybe I need to add a wait? But where?
Here’s what I did. I put inround = false like this:
if #runnersTable < 1 then
break
end
InRound.Value = false
When I did it, it would do what it did earlier (blip into the game time for a second as well as teleport players then go back). When I did it like this:
if #runnersTable < 1 then
InRound.Value = false
break
end
In any language, local variables will be faster.
You will need to understand what a register is and what the thread stack is to understand my explanation.
Most local variables are implemented as a register variable or pushed near the top of the local stack, so they are generally accessed much more quickly.
Global variables are stored further up the stack (if they are not on the heap) so computing their address to access them is slower.