Count dead players.

Is there a way to count how many dead players are on a server ?
Ex: if dead players is > 0 then … end

Something like this?




function GetDeadPlayerCount()
    local deadPlayers = 0

    for _, ply in pairs(player.GetAll()) do
        if not ply:Alive() then
            deadPlayers = deadPlayers + 1
        end
    end
    
    return deadPlayers
end



EDIT: ninjas


local dead = 0

for k, v in pairs( player.GetAll() ) do
	if !v:Alive() then
		dead = dead + 1
	end
end