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.