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)