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

Cant detect dead player?

humanoid:GetState() == Enum.HumanoidStateType.Dead then

Im using this in a if statement, and it doesn't work. It is in a local script. Asking before bed so wont answer for 8 hours.

Thanks for the help.

2 comments

0

you doing this on a loop? if not, try placing it on one

0

Try adding a "wait()" in the script so it doesn't execute immediately when the game starts

4 answers

You can use a loop to check if the State is dead. Example:

while wait() do -- The loop, add the wait() so it doesnt crash
if humanoid:GetState() == Enum.HumanoidStateType.Dead then -- If there's already a variable called humanoid in your script
print("He's dead")
end
end

Hope this helps.

You can try this

if humanoid.health = 0 then
	print("I think he is D e a d")
end

There is an event called died that can be fired, syntax is like this:

local humanoid=script.Parent.Humanoid
humanoid.Died:Connect(function()
print("I Died")
end)

make a local script inside of starterpack and type this

local hum = game.Players.LocalPlayer
if hum.Character.Health == 0 then
print("Player Has Died"

if this helped accept my answer!

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