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

(Solved) humanoid.Died not firing whatsoever?

Asked by 1 year ago
Edited 1 year ago

I want to destroy an NPC whenever they die, but I just can't seem to get this to work. No output errors, only print("test") shows in output.

Screenshot of my pathing

Code (Server script parented under Enemy's model named "EnemyDeath")

local humanoid = script.Parent:WaitForChild("Humanoid")
local RunService = game:GetService("RunService")
print("test")

RunService.Heartbeat:Connect(function(deltaTime)
    humanoid.Died:connect(function()
        humanoid.Parent:Destroy()
        print("destroy!")
    end)
end)
1
Why do you have the Died event in the Heartbeat event? xInfinityBear 1777 — 1y
0
it was my best attempt at a fix, it still didn't work though brandons2005 87 — 1y
1
Don't see why this wouldn't be working.. Are you dealing damage to the Humanoid from the server or client? xInfinityBear 1777 — 1y
0
Ahhhhh, that's probably it, I was dealing damage from the client brandons2005 87 — 1y
View all comments (2 more)
0
yeah it works now, thank you that was really getting on my nerves brandons2005 87 — 1y
1
No problem. xInfinityBear 1777 — 1y

Answer this question