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

6 comments
Why do you have the Died event in the Heartbeat event?
it was my best attempt at a fix, it still didn't work though
Don't see why this wouldn't be working.. Are you dealing damage to the Humanoid from the server or client?
Ahhhhh, that's probably it, I was dealing damage from the client
yeah it works now, thank you that was really getting on my nerves
No problem.