NPC animation breaks when I get near it

  1. What do you want to achieve?
    I want an NPC to walk from one point to another. I am using path finding for this.

  2. What is the issue?
    When I get near the NPC its animation breaks. (I’ve included a video if needed) https://gyazo.com/a0cedd3829edfe7bf30a0fb5ce4b6219

  3. What solutions have you tried so far?
    I’ve tried to fix any errors there might be in the animation script, but I couldn’t find any. As said earlier I’m using the pathfinding service. There aren’t any errors displayed in the output.

(The animation script is the same as the player animation script. I can’t include it here as it’s very long)

Heres my pathfinding script:

local PathfindingService = game:GetService("PathfindingService")
	 
	local merchant = game.Workspace["Travelling Merchant"]
	local humanoid = merchant.Humanoid
	local humroot = merchant:WaitForChild('HumanoidRootPart')
	
	local destination = game.Workspace.TravellingMerch1
	 
	local path = PathfindingService:CreatePath()
	 
	local waypoints
	local currentWaypointIndex
	 
	
	local function followPath(destinationObject)
		path:ComputeAsync(humroot.Position, destinationObject.PrimaryPart.Position)
		waypoints = {}
	 
		if path.Status == Enum.PathStatus.Success then
			waypoints = path:GetWaypoints()
			currentWaypointIndex = 1
			humanoid:MoveTo(waypoints[currentWaypointIndex].Position)

		else
			humanoid:MoveTo(humroot.Position)
		end
	end
	 
	local function onWaypointReached(reached)
		if reached and currentWaypointIndex < #waypoints then
			currentWaypointIndex = currentWaypointIndex + 1
			humanoid:MoveTo(waypoints[currentWaypointIndex].Position)
		end
	end
	 
	local function onPathBlocked(blockedWaypointIndex)
		if blockedWaypointIndex > currentWaypointIndex then
			followPath(destination)
		end
	end
	 
	path.Blocked:Connect(onPathBlocked)
	 
	humanoid.MoveToFinished:Connect(onWaypointReached)
	 
	followPath(destination)

Any help would be really appreciated!