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

How would you tell if the humanoid died?

Asked by 3 years ago
Edited 3 years ago

I know there are questions like this out there, but none of them answer what I'm confused about. I even looked on the developer websites to see if it was possible, but it was not explained well enough.

I'm trying to make a script that when a humanoid's health reaches 0, then the model the humanoid is in gets deleted. I've tried .Died but it doesnt seem to work in this case because when I use it it instantly deletes the model, even before the health is 0 and the head is disconnected from the torso. I need to know how to tell when the humanoid has died.

local humanoid = script.Parent.Humanoid

if humanoid.Health == 0 then
        script.Parent:Destroy()
end

If the way the script is formulated is wrong please point it out.

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Humanoid.Died:Connect(blah) OR Humanoid.Died:Connect(function()

depends on what you like and btw your code only runs once so it wouldnt detect if they die at any time

and it deletes the model instantly cuz u made it to lol just add a wait or something

like this (i do it this way but you can do it the other way):

local humanoid = script.Parent.Humanoid

Humanoid.Died:Connect(function()
    wait(5)
        script.Parent:Destroy()
end)
0
Where and how would you add the wait? Pyro_dood 31 — 3y
0
add the wait() before the 'Destroy()' line, maybe about 5 seconds. speedyfox66 237 — 3y
1
Thanks! It worked. Pyro_dood 31 — 3y
0
<h1>a</h1> codingMASTER398 52 — 3y
Ad

Answer this question