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
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