Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

for i = 60,0,-1 do
		if i == 0 then
			status.Value = 'Game Over, Prepare For Next Round!'
			break
		end
		wait(1)
		if #_G.gameplayers == 1 then
			for i, v in pairs(_G.gameplayers) do
				if v ~= nil then
					status.Value = v..' Has Won!'
					game.Players[v].leaderstats.Coins.Value = game.Players[v].leaderstats.Coins.Value + 15
					game.Players[v].leaderstats.Wins.Value = game.Players[v].leaderstats.Wins.Value + 1
					break
				end
			end
			break
		else
			status.Value = i..' Seconds Left!'
		end
	end

2 answers

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

You put a ' instead you needed to put "

So this should work!

for i = 60,0,-1 do
        if i == 0 then
            status.Value = "Game Over, Prepare For Next Round!"
            break
        end
        wait(1)
        if #_G.gameplayers == 1 then
            for i, v in pairs(_G.gameplayers) do
                if v ~= nil then
                    status.Value = v.." Has Won!"
                    game.Players[v].leaderstats.Coins.Value = game.Players[v].leaderstats.Coins.Value + 15
                    game.Players[v].leaderstats.Wins.Value = game.Players[v].leaderstats.Wins.Value + 1
                    break
                end
            end
            break
        else
            status.Value = i.." Seconds Left!"
        end
    end

1 comment

0

I was reviewing the script, and I found that you put a ' instead of the "

This discussion is preserved as it was. New answers, comments, and votes are closed.