While using the pathfinding service, I notice that after maybe 20-30 seconds of pathfinding it will start to jitter. It is almost like the rig is teleporting short distances. I am wondering how I can prevent this
local npc = script.Parent
local humanoid = npc:WaitForChild("Humanoid")
local location1 = workspace.Location1
local location2 = workspace.Location2
local location3 = workspace.Location3
local function followPath(destPart)
-- creates the settings for the path
local path = PathfindingService:CreatePath({
AgentRadius = 3,
AgentHeight = 6,
AgentCanJump = true,
-- Costs = {}
})
-- Computes the path from param 1 to param 2
local success, errorMessage = pcall(function()
path:ComputeAsync(npc.PrimaryPart.Position, destPart.Position)
end)
-- if the path was successfully created, then...
if success and path.Status == Enum.PathStatus.Success then
-- get waypoints and move to each one of them
for _, waypoint in path:GetWaypoints() do
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid.Jump = true
end
-- move humanoid to the next waypoint
humanoid:MoveTo(waypoint.Position)
-- go to next waypoint once current wp is reached
local status = humanoid.MoveToFinished:Wait()
end
end
end
while true do
followPath(location1)
wait(10)
followPath(location2)
wait(10)
followPath(location3)
wait(10)
followPath(workspace.Adsfinity.PrimaryPart)
wait(10)
end```