Trouble with Pathfinding + Chasing Player

So I understand what you mean when it continuously updates(because i continuously compute a path) so it should just move to the next waypoint) however it looks kind of buggy and gives me an error AFTER I stop the simulation, this may not affect the overall function but I just like to keep things tidy or at least understand the reason behind some stuff.

Video:

This happens because of how ROBLOX handles its network ownership, ROBLOX automatically sets parts network ownership to the nearest player (which is why this only happens after a set amount of time chasing)

You can fix this by forcing the NPC’s network ownership to the server:

-- line 9
local GrimaceModel = script.Parent
local Humanoid = GrimaceModel:WaitForChild("Humanoid")
local G_HumanoidRootPart = GrimaceModel:WaitForChild("HumanoidRootPart")

GrimaceModel.PrimaryPart:SetNetworkOwner(nil)

And for the error, that’s happening because there’s no check to see if the target player exists, here is a fix for that:

-- line 155
local targetsName = Humanoid:GetAttribute("TargettingPlayer")
local targetsPlayer = game.Players:FindFirstChild(targetsName)
if not targetsPlayer then return end
local targetsChar = targetsPlayer.Character or targetsPlayer.CharacterAdded:Wait()
local targetsHRP = targetsChar:WaitForChild("HumanoidRootPart")
1 Like

Sorry for the late response but Im typing this jusr after I tested your code, it works but there is one more problem: sometimes when i take turns or sharp turns where the grimace is right behind me sometimes(but not mostly) it goes another path or ignores its path params where it keeps a certain distance from the wall, im thinking of implementing a distance judger to judge the distance between the grimace and where its going since it has its hands out to its front which is the most realistic thing to do. Im not sure if there is a better alternative or work around but if you have a solution, suggestion, etc. Please make it known. :grin:

Still stuck on this problem btw