How to make my npc's body parts remove on death while keeping respawn?
So when my npc's die their body parts scatter how would I remove this? Main script for animations/movement is here. https://pastebin.com/Awe5RYGm The script is so big it cant be posted but also this is a follow script so when it detects players it will follow the player if you need or want it.
01 | function findNearestPlayer(Position) |
03 | local List = game.Workspace:GetChildren() |
07 | for i, v in pairs (List) do |
08 | local humanoid = v:FindFirstChild( "Humanoid" ) |
09 | local hrp = v:FindFirstChild( "HumanoidRootPart" ) |
11 | if humanoid and hrp and v ~ = script.Parent then |
12 | local dist = (Position - hrp.Position).Magnitude |
13 | if dist < = Distance and humanoid.Health > 0 then |
14 | local plr = game.Players:GetPlayerFromCharacter(v) |
26 | local target = findNearestPlayer(script.Parent.HumanoidRootPart.Position) |
28 | script.Parent.Humanoid:MoveTo(target.Position, target) |
I also want to keep the ability to respawn but if I put this script in,
1 | local humanoid = script.Parent:FindFirstChild() |
3 | warn( "Humanoid is nil!" ) |
5 | humanoid.Died:Connect( function () |
6 | local Char = script.Parent |
I wouldnt be able to make the npc respawn. I heard if keep a copy in server storage and copy that and the place the npc respawns I could keep both? I need assistance