Animation Code Not Working

  1. I am trying to animate a custom character.

  2. My Issue The code isn’t working and nothing is happening.

  3. I have tried I have changed the humanoid hip height but it didn’t work and the character has a Animator.

Here is the code in a In a Local Script in StarterCharacterScript:

local runAnim = script:WaitForChild("WalkAnim") --the walk animation

local humanoid = script.Parent.Humanoid

local animTrack = false --for doing extra code on top

humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	animTrack = humanoid:LoadAnimation(runAnim)
	if not animTrack then --if not already plying
		animTrack:Play() --play animation
		
		repeat wait() until humanoid.MoveDirection.Magnitude <= 0 --wait into player has stopped
		
		animTrack:Stop() -stop animation
	end
end)

Thx for the help :slight_smile:

1 Like

there is two animTracks so you might have got the boolean here, I think rename the things and that would work.

1 Like

Try to change

if not animTrack then 

to

if animTrack.IsPlaying == false then

You’re also loading the animation every time the player walks so try to put humanoid:LoadAnim out of the function.

1 Like