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

Checking if all players are dead?

Asked by 9 years ago

I'm basically trying to make a game; a round based game; and I want to check if all the players in the game are dead, so that the game can end if all the players are dead and not just waiting for the round to end. But also, there's a player that's the "craze" who has to kill all players before they escape, so is there a way I can check if all the players are dead except the craze? I have the craze stored as the variable "craze" just in case you need that reference. This is where I'm trying to check if all the players except the craze are dead;

for i = gametime, 0, -1 do

    status.Value = "Round In Progress (01:" .. i .. ")"
    if i < 10 then
        status.Value = "Round In Progress (01:0" .. i .. ")"
    end
    wait(1)
end
0
Please help :( passtimed 45 — 9y

2 answers

Log in to vote
2
Answered by
Ryzox 220 Moderation Voter
9 years ago
function checkPlayers()
    for _,v in pairs(game.Players:children()) do
        if v ~= craze then -- assuming craze is equal to the player
            if v.Character and v.Character:findFirstChild("Humanoid") then
                if v.Character:findFirstChild("Humanoid").Health == 0 then
                    return true
                end
            end
        end
    end
end

Try that.

0
ty passtimed 45 — 9y
Ad
Log in to vote
0
Answered by 3 years ago
for _, v in pairs(game.Players:GetPlayers()) do
    v.Character.Died:Connect(function()
        -- run code
    end)
end

Answer this question