MoveTo() hiccupy animations

Im using pathfinding for my ai animals but the problem is that the animation for walking is not smoooth and is basically hiccupy and then sometimes the idle animation just stop entirely

local function wander()
		
		-- randomStuff
		local randX = math.random(-15,15)
		local randZ = math.random(-15,15)
		local goal = humanoidRootPart.Position + Vector3.new(randX,0,randZ)
		
		-- Services
		local path = game:GetService("PathfindingService"):CreatePath()
		path:ComputeAsync(humanoidRootPart.Position, goal)
		
		local points = path:GetWaypoints()
		if path.Status == Enum.PathStatus.Success then
			for _, point in pairs(points) do
				if point.Action == Enum.PathWaypointAction.Jump then
					humanoid.Jump = true
				end
				humanoid:MoveTo(point.Position)
				humanoid.MoveToFinished:Wait()
			end
		else
			print("Path failed")
		end
		
	end
	
	while wait(math.random(2,5)) do
		wander()
	end

In my guess its just the Thread overheating. Try creating a new Thread using coroutines and closing it after the Humanoid reached the finish point.

Alright ill try that and get back to you

edit : Im not sure if I did it wrong or something but the problem persists @IuaNerd

Im not very good at scripting so would I just put a wait after MoveTo?

I think this is because it’s something to do with SetNetworkOwnership. Because in Roblox, clients or servers can calculate a part’s physics but only one of them can take the priority. So if you go too near the NPC, the NPC’s network ownership would be confuse because it would switch to client and then to the server and then vice versa. So, to solve this just set the model’s primary part’s network owner to the server.

Model.PrimaryPart:SetNetworkOwner(nil)

For more informations, click here.

Alright let me try that really quickly

Wait actually your wrong I am waiting until they can move again because Im using the MoveToFinished function, make sure you read carefully before replying

I tried setting it to player and then nil and it still doesnt wanna work and the animations are still hiccuping

edit : IT WORKS, thank you so much man @ItzMeZeus_IGotHacked it also fixed the stopping of the idle!

1 Like