Hello guys again! I come to you with a new issue.
In the game I am making, I have a script that makes the NPC follow the player, but..
If the player gets hit by the enemy mob and dies, the enemy mob continues following the player when the player respawns as it is expected to do. However..since there are gaps players are to jump over, if the player falls into the void; the enemy NPC wont follow the player after the player respawns.
local aihumroot = script.Parent.HumanoidRootPart local aihum = script.Parent.Humanoid while true do for _,plr in pairs(game.Players:GetPlayers()) do if plr.Character then local char = plr.Character if (char.HumanoidRootPart.Position-aihumroot.Position).magnitude <= 30 then aihum:MoveTo(char.HumanoidRootPart.Position) end end end wait() end
This is the current code I have.
(credit to Eagle022 for helping me simplify and understand where I went wrong in my original code btw)
maybe do this when the players character is loaded also add the enemy into the lighting
local position = game.Workspace.(enemynamehere).HumanoidRootPart.CFrame game.Workspace.(enemynamehere):Remove() game.Lighting.(enemynamehere):Clone().Parent = game.Workspace game.Workspace.(enemynamehere).HumanoidRootPart.CFrame = position
might not work, might be wrong, I just thought of it at the top of my head, its not the most effective & practical way but it might work, enjoy, :)!!!!!!!