NPC run animation not playing

Hello, I am working on a pathfinding system for a game, this system runs locally and works fine, now I am working on adding the animations that I had made to the game.

My problem with this is, even though I am getting no errors the animation is still not playing, I am unsure what the problem could be. Below this will be a short version of the code.

-- THIS IS A LOCAL SCRIPT, DOING THE PATHFINDING LOCALLY SEEMED MORE LOGICAL
-- Declare variables for stuff like PathfindingService, Player, Characters (A folder in replicated Storage), ReplicatedStorage

-- Declare animation variables. 

function ComputePath(startGoal:Vector3, endGoal:Vector3)
   -- Code used to compute the path, then if its success it returns the path
end

function WalkToWaypoint(humanoid:Humanoid, startGoal:Vector3, endGoal:Vector3)
   -- This is where the animations will be used
    local Animator = humanoid:WaitForChild("Animator")
	local RunTrack = Animator:LoadAnimation(RunAnimation)

	RunTrack.Priority = Enum.AnimationPriority.Movement
	RunTrack.Looped = true

    local Path = ComputePath(startGoal, endGoal)
	RunTrack:Play()
    local Waypoints = Path:GetWaypoints()
	local CurrentWaypointIndex = 2 -- the point to go after the first point
	
	local MovedToFinishConnection:RBXScriptConnection

	MovedToFinishConnection = humanoid.MoveToFinished:Connect(function(reached)
		if reached then -- if the humanoid reached the waypoint within 8 seconds
			if CurrentWaypointIndex < #Waypoints then -- if we have not cycle through the last waypoint
				CurrentWaypointIndex += 1 -- we increase the index by 1 so that the humanoid moves to the next waypoint
				humanoid:MoveTo(Waypoints[CurrentWaypointIndex].Position) -- and the same thing
				RunTrack:Play()
				if Waypoints[CurrentWaypointIndex].Action == Enum.PathWaypointAction.Jump then
					humanoid.Jump = true
				end
			else -- we cycled the whole path series!
				print("Path reached!")
				HasFinised = true
				MovedToFinishConnection:Disconnect() -- disconnect the unnecessary event to avoid memory leaks
				RunTrack:Stop()
			end
		else -- failed to reach waypoint within 8 seconds, the dummy probably is stuck, so let's recompute it!
			MovedToFinishConnection:Disconnect() -- disconnect the unnecessary event to avoid memory leaks
			WalkHumanoid(humanoid, StartingPoint.Position, endGoal) -- we are changing our start goal and replacing it to the current position of our dummy instead of reusing the old one
		end
	end)	
	
    humanoid:MoveTo(Waypoints[CurrentWaypointIndex].Position)
	if Waypoints[CurrentWaypointIndex].Action == Enum.PathWaypointAction.Jump then
		humanoid.Jump = true
	end
end

-- More code below, but not relevant to the problem.

I tried finding solutions on Youtube, the DevForum and even the Documentation, but I can’t seem to figure out what the problem is. So I decided to make this post to ask for help.

If you have any other questions just ask and I will see if I can answer them as soon as possible. Thank you for reading, and for your support.

What is the animations priority? I would assume the animation itself would be the problem in this situation since you’re not getting any syntax errors.

I will set that now, and see if it fixes the problem, i had it set before but i changed it so much and guess i forgot to add it again. Will let you know if that fixes the problem. :smiley:

Oh I have set the priority of the animation, Let me mention this, We hired someone to do the animations and they did it in Moon Animator, I exported them and published them to the Roblox group which the game is made on.

Maybe just load the animation on the humanoid directly.
BTW Idk why you unfriended me on my main @RobloxMastersTeam1.
Anyways, Happy New Year !

I have tried that and it didnt work, and I didnt unfriend someone in quite a while, but I will add you again then ig.

Alr, we actually met each other in my game which I asked feedback here called ro clicker (now Clicker Infernos), also the humanoid trick works many times, but ok.

oh I remember now, i dont remember unfriending though but i might have, im not sure.

Nevermind I fixed the problem, I think I either used the wrong rig or there were stuff missing in the npc.

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