Weird Pathfinding Stutters After Every Waypoint

I have been experiencing a really weird stuttering issue with my pathfinding. I have tried to leave the server ownership alone, making it all client, making it all server, I’ve tried various versions of waits using MoveToFinished:Wait(), MoveToFinished:Connect(function), I’ve made a variable based wait where it waits until the varible changes, and I’ve tried to wait until a variable is = to the current waypoint. I’ve done everything that I have thought of to try to fix this lag and it’s always there in some capacity, sometimes it works perfectly for 10 seconds and sometimes it’s laggy from the start. Here is a video of what it looks like.


Note: The tweening rotation at the end of some nodes is my doing and not part of the lag, nor does it affect the rest of the movement as it’s completely separate from the movement.

Here is my current code for the pathfinding.

function npcModule.MoveTo(npc, targetPoint)
	local pathParams = {
		AgentRadius = 3.5, -- default: 2.0
		AgentHeight = 5.0,
		AgentWalkableClimb = 2.0,
		AgentCollisionGroupName = "NPC_Collisions",
		CollectionWeights = {Bridge = 2.5, Minefield = math.huge},
		MaterialWeights = {Water = 1.5},
		AgentCanJump = false
	}
	
	local path = PathFindingService:CreatePath(pathParams)
	path:ComputeAsync(npc.HumanoidRootPart.Position, targetPoint.Position)
	
	for i, waypoint in pairs(path:GetWaypoints()) do
		npc.Humanoid:MoveTo(waypoint.Position)
		npc.Humanoid.MoveToFinished:Wait()
	end
end

I have looked through the dev forums already but I couldn’t find any posts that had the same issue and was solved.

2 Likes

i wasn’t able to repro this issue, could you send a copy of this test place?

1 Like

pathfinding_stuttering.rbxl (75.9 KB)
from my experience it happens a lot more when your actually in the roblox game but here is the place

1 Like

the issue seems to only be present on your client, everything works as intended for me. file a bug report

Try setting the model’s network owner to nil. It makes only the server handle it instead of switching between that and client Root:SetNetworkOwner(nil)

Was having this same issue and this seemed to work for me. Should be marked as a solution (assuming it worked for OP as well, which judging by their silence it might have)

maybe try using Humanoid.WalkToPoint instead

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