Hello, good afternoon, I want to eliminate the NPCs when they die, I have seen here a question that said how to do it I fixed the code, I read all about the RemoteEvent and I do not know what I'm doing wrong, I have the NPCs that are a model within that model I have 2 parts, which are the PathfindingService locations, this is the Npc model and denote a LocalScript with this.
local event = game.ReplicatedStorage.DiedEnemy
event.OnClientEvent:Connect(function()
print("Humaoid died!")
end)
And in the Workspace I have a script with this.
wait(3)
local enemy = game.Workspace.Enemy.Enemy
local event = game.ReplicatedStorage.DiedEnemy
function Dead()
enemy.Parent:Destroy()
event:FireAllClients()
end
enemy.Humanoid.Died:Connect(Dead)
Thanks and see if I solve it with your help.

6 comments
line 8 you misspelt destroy
Thank you very much for your work and your time but it does not work for me, but thank you very much, I think it will be because the model of the npc is inside the model that contains the 2 parts of the routes that it follows.
Nor is that because I have removed the npc from the main model in the workspace and it does not work either, it does not destroy it, many thanks anyway and I am sure it will be for something and I will discover it. I already have a great guide of where things are going.
Brok3 just make sure your enemy is a model in workspace. The model has a Humanoid in it and tthat's all it takes.
Thank you already solve it, thank you very much.
np