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.
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)