NPC Pathfinding Stutter!

I’m currently having an issue as I’ve just started using pathfinding where my NPC is stuttering. I’ve looked up how to fix it like setnetworkowner(nil) but it doesn’t seem to work. I don’t know if there’s an issue with movetofinished or whatever. It’s also not smooth, and seems to find the path slowly. Here’s an example below

this is the code below

local function NPCScript()
	local Target = nil
	local studs = 200
	for _, v in workspace:GetChildren() do
		local HumanoidRootPart = v:FindFirstChild("HumanoidRootPart")
		if HumanoidRootPart and HumanoidRootPart ~= NPCHUmanoidRootPart and HumanoidRootPart ~= script.Parent and HumanoidRootPart:GetAttribute("OtherNPC") == false then
			if (HumanoidRootPart.Position - NPCHUmanoidRootPart.Position).Magnitude < studs then	
				studs = (HumanoidRootPart.Position - NPCHUmanoidRootPart.Position).Magnitude
				Target = HumanoidRootPart
				
			end
		end
	end
	return Target
end

local Path = PathFindingService:CreatePath({
	AgentRadius = 2,
	AgentHeight = 5,
	AgentCanJump = true,
	AgentCanClimb = false,
	WaypointSpacing = 4
})



for i, v in Rig:GetChildren()  do
	if v:IsA("BasePart") then
		v:SetNetworkOwner(nil)
	end
end

while true do
	
local HumanoidRootPart = NPCScript()


	if HumanoidRootPart then
		

		
		local Success, Unsuccessful = pcall(function()
			Path:ComputeAsync(NPCHUmanoidRootPart.Position, HumanoidRootPart.Position)
		end)
		
		local Waypoints
		
		if Success and Path.Status == Enum.PathStatus.Success then
			Waypoints = Path:GetWaypoints()
		end
		

		
		for _, Waypoint in Waypoints do
			NPCHumanoid:MoveTo(Waypoint.Position)
			NPCHumanoid.MoveToFinished:Wait()
		end
	else
		
	end
	wait()
end

Firstly you only need to set the network owner of the primary part to nil but that isn’t the problem. One solutions I came up with is repeatedly get the position of the target and make it move to the second waypoint

Humanoid:MoveTo(Waypoints:GetChildren()[2])

Now there could only be one waypoint if the npc is very close

if #Waypoints:GetChildren() == 1 then
    Humanoid:MoveTo(Waypoints:GetChildren()[1])
else
    Humanoid:MoveTo(Waypoints:GetChildren()[2])
end

Don’t use pathfinding when there’s nothing blocking the way between the player and the npc (the reason behind the delay is because it takes time to recalculate the path every loop, which this method easily fixes)

To do this, raycast from the npc to the player and if there isn’t anything blocking the raycast, just move the npc to the players position otherwise use pathfinding

The reason that it is stuttering is because it is updating too slowly due to waiting for the agent to walk 4 studs . Thus , you should decrease the spacing between each waypoint so that it updates more frequently