Pathfinding Laggy

The Character stops moves and stops again for some reason. Here is the code:

local path = pathfinding:CreatePath()


path:ComputeAsync(Body.Position,Dest)

local WayPoints = path:GetWaypoints()

for k, waypoint in pairs(WayPoints) do
	hum:MoveTo(waypoint.Position)
	
	if waypoint.Action == Enum.PathWaypointAction.Jump then
		hum:ChangeState(Enum.HumanoidStateType.Jumping)
	end
	
	hum.MoveToFinished:Wait(2) -- make this wait() maybe?
end

I tried changing hum.MoveToFinished:Wait(2) to hum.MoveToFinished:Wait() it didn’t help.

3 Likes

Try setting the network owner of the character to the server (nil).
Network Ownership | Documentation - Roblox Creator Hub

2 Likes

Try removing 2…

I have this problem too! When npc sit on the seat, pathfinding is laggy after this

i already set network owner to nil

Just do hum.MoveToFinished:Wait()

1 Like

Set the run anim looped to true, if you using default roblox anim, it set to false by default

if that doesnt work, SetNetworkOwner to nil so the server can control it

for i,v in pairs(NPC:GetChildren()) do
	if v:IsA("BasePart") then v:SetNetworkOwner(nil) end
end
1 Like

Try using runservice and render stepped in place of your current wait(). This may smooth things out since run service is frame based not time based.

1 Like

Try wait(.004) that may help [or a smaller number like 001]

1 Like

Wow, thank you. Apparently your reply have became a solution to the same problem I was facing. Thanks!

1 Like