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

Checking if all players are dead?

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

1 comment

0

Please help :(

2 answers

✓ Accepted answer
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.

1 comment

0

ty

for _, v in pairs(game.Players:GetPlayers()) do
	v.Character.Died:Connect(function()
		-- run code
	end)
end

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