Changing NPC's Walk and Idle animations at runtime

When equipping a weapon i want their walk and idle animation to change

Issue is that it doesnt change, it works on player but not npc

Moving the npc forward in hope to refresh their anims

   				-- Play equip animation
				local track = humanoid:LoadAnimation(animations.Weapons[weapon].Equip)
				track:Play()
				track.Stopped:Connect(function()
					track:Destroy()
				end)

				-- Update idle & walk animations
				local wAnims = animations.Weapons[weapon]
				if wielder:FindFirstChild("Animate") then
					wielder.Animate.idle.Animation1.AnimationId = wAnims.Idle.AnimationId
					wielder.Animate.idle.Animation2.AnimationId = wAnims.Idle.AnimationId
					wielder.Animate.run.RunAnim.AnimationId = wAnims.Walk.AnimationId
					wielder.Animate.walk.WalkAnim.AnimationId = wAnims.Walk.AnimationId
				end

				-- Move NPC a small step forward
				if humanoid and wielder.PrimaryPart then
					local forward = wielder.PrimaryPart.CFrame.LookVector
					local targetPos = wielder.PrimaryPart.Position + forward * 5
					humanoid:MoveTo(targetPos)
				end

Any help is appreciated

1 Like

Try loading the animation on an Animator inside the humanoid instead of loading it on the humanoid since that version is deprecated.

1 Like