[SOLVED] Problem With Pathfinding NPCs Walking Wierdly After A Little While

Post been edited, problem occurs just after a little while.

I have a problem with Pathfinding NPCs walking strange and slow after a little while.
Here is a video showing the problem:

This is the code that does the pathfinding:

local pfs = game:GetService("PathfindingService")
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local waypoints = workspace.Waypoints2:GetChildren()
local tpos

while true do
	wait(1)
	if script.Parent:WaitForChild("Humanoid").Health < 1 then return end
	local randomwp = waypoints[math.random(1, #waypoints)]
	local path = pfs:CreatePath()
	path:ComputeAsync(hrp.Position, randomwp.Position)


	if path.Status == Enum.PathStatus.Success then
		local wps = path:GetWaypoints()

		for i,v in pairs(wps) do
			if v.Action == Enum.PathWaypointAction.Jump then
				hum.Jump = true
			end
			hum:MoveTo(v.Position)
			hum.MoveToFinished:Wait()
		end

	end
end

Any help is appreciated.

Set the network owner of the humanoidrootpart to nil ( the server). The issue is occurring when Roblox automatically sets the network owner to the nearest player.

HumanoidRootPart:SetNetworkOwner(nil)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.