Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this continue to countdown, even when the game was supposed to end?

Asked by 7 years ago

It tests to see if there is 1 player left, it works sometimes but usually after a couple of rounds (give or take a few) it will start counting down all the way to 0, even when the game should end.

01for i = 60,0,-1 do
02        if i == 0 then
03            status.Value = 'Game Over, Prepare For Next Round!'
04            break
05        end
06        wait(1)
07        if #_G.gameplayers == 1 then
08            for i, v in pairs(_G.gameplayers) do
09                if v ~= nil then
10                    status.Value = v..' Has Won!'
11                    game.Players[v].leaderstats.Coins.Value = game.Players[v].leaderstats.Coins.Value + 15
12                    game.Players[v].leaderstats.Wins.Value = game.Players[v].leaderstats.Wins.Value + 1
13                    break
14                end
15            end
16            break
17        else
18            status.Value = i..' Seconds Left!'
19        end
20    end

2 answers

Log in to vote
0
Answered by 7 years ago

You have told it to die when there are no players left, this means that it will kill the script and the timer.

Ad
Log in to vote
0
Answered by 7 years ago

You put a ' instead you needed to put "

So this should work!

01for i = 60,0,-1 do
02        if i == 0 then
03            status.Value = "Game Over, Prepare For Next Round!"
04            break
05        end
06        wait(1)
07        if #_G.gameplayers == 1 then
08            for i, v in pairs(_G.gameplayers) do
09                if v ~= nil then
10                    status.Value = v.." Has Won!"
11                    game.Players[v].leaderstats.Coins.Value = game.Players[v].leaderstats.Coins.Value + 15
12                    game.Players[v].leaderstats.Wins.Value = game.Players[v].leaderstats.Wins.Value + 1
13                    break
14                end
15            end
16            break
17        else
18            status.Value = i.." Seconds Left!"
19        end
20    end
0
I was reviewing the script, and I found that you put a ' instead of the " ZAZC_Noob 7 — 7y

Answer this question