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

When round is over make all the players die once?

Asked by 8 years ago

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
0
It does that because you put it in a while loop. Remove the while loop. Lacryma 548 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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

0
Nope didn't work sorry ;( docrobloxman52 407 — 8y
Ad

Answer this question