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

When round is over make all the players die once?

Hi I was making a game script and I made it so that if the round is over then everyones dies. But with my script it makes a constant death. Please help?

local gameOver = false

while true do
wait()
    for _, player in next, game.Players:GetPlayers() do
        if getScore(player, "Cow Clicks") >= highScore then
            gameOver = true
        end
    end

    if gameOver then
	warn("wins")
	wait(1)
	for i,v in pairs (game.Players:GetChildren()) do
		v.Character.Humanoid.Health = 0

   end
end
end

1 comment

0

It does that because you put it in a while loop. Remove the while loop.

1 answer

✓ Accepted answer

Once you checked if gameOver, you forgot to set gameOver back to false. Once you have made it true, with your code it will never be false. This should do it:

while true do
wait()
    for _, player in next, game.Players:GetPlayers() do
        if getScore(player, "Cow Clicks") >= highScore then
            gameOver = true
        end
    end

    if gameOver then
	gameOver=false
    warn("wins")
    wait(1)
    for i,v in pairs (game.Players:GetChildren()) do
        v.Character.Humanoid.Health = 0     
   end
end
end

1 comment

0

Nope didn't work sorry ;(

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