Pathfinding stutters

My pathfinding enemy is stuttering. I’ve tried adding :SetNetworkOwner(nil) like some other people but that doesn’t seem to work. Its my first time using network owner thingy so maybe i messed something up

Script:

local RunService = game:GetService("RunService")
local Players  = game:GetService("Players")
local PathfindingService = game:GetService("PathfindingService")

function Chase()
	local path = PathfindingService:CreatePath()
	script.Parent.HumanoidRootPart:SetNetworkOwner(nil)
	for i, v in pairs(Players:GetPlayers()) do
		if v.Character then
			path:ComputeAsync(script.Parent.HumanoidRootPart.Position, v.Character.HumanoidRootPart.Position)
			if path.Status == Enum.PathStatus.Success then
				local waypoints = path:GetWaypoints()
				for waypointIndex, waypoint in pairs(waypoints) do
					script.Parent.Humanoid:MoveTo(waypoint.Position)
					script.Parent.Humanoid.MoveToFinished:Wait()
				end
			end
		end
	end
end

RunService.Heartbeat:Connect(Chase)

Probably this is the issue since this property is kinda broken. So just don’t do if statements in this case.

still npc is jittering even without it

Set network ownership to the player instance the NPC is currently chasing or to the NPC itself, there’s no reason why the server should be the network owner.

should i do :SetNetworkOwner(script.Parent) or just delete that line?

i used it cause other people on forum got adviced to do :SetNetworkOwner(nil) and they were happy with the result

Hello, I have ran into this issue before. At least I am guessing it is this issue.
What you should do. Is set the primarypart’s network owner to nil. This should fix the problem

local model = NPCModel
model.PrimaryPart:SetNetworkOwner(nil)

Hope that helps!

3 Likes