Last time I had trouble with the NPC follow script not working when the player dies, but now it's when the NPC dies the follow script stops working. I've tried cloning the script in many ways when he dies but that doesn't seem to work. Here is the follow script:
function ready(tmp_plr) game:GetService("RunService").Stepped:connect(function() local yes, error = ypcall(function() if (math.abs((tmp_plr.Character.Head.Position-script.Parent.Head.Position).magnitude)) < 90 then script.Parent.Humanoid:MoveTo(tmp_plr.Character.Head.Position) end end) end) end game.Players.PlayerAdded:Connect(function(p) ready(p) end)
Here's the script that makes him respawn:
robo = script.Parent:Clone() while true do wait(0.1) if script.Parent ~= nil then if script.Parent.Humanoid.Health < 1 then wait(10) script.Parent.DetectionScript:Destroy() game.ReplicatedStorage.DetectionScript:Clone().Parent = script.Parent robot = robo:Clone() robot.Parent=script.Parent.Parent robot:MakeJoints() Instance.new("ForceField",robot) script.Parent:Destroy() wait(5) robot.ForceField:Destroy() end end end
"DetectionScript" is the name of the follow script, and I made a duplicate in ReplicatedStorage but that didn't seem to work well. I also tried to put that line under robot.ForceField:Destroy() but the output said "Parent is a nil value"
Caught something! From the top of your script, it says that the variable name is 'robo'.
And the rest says 'robot'. Please fix that!