Why won't my custom walking animation script work?

I have a custom walking animation script because I have a custom character in this game of mine.
I have three animations I have made for it: Walking, Dashing, and Jumping.
Dashing and Jumping ones work, but for some reason the walking animation will not work.

Heres the walking animation script:

local walkanim = game.ReplicatedStorage.Animations.Walk
local walk = script.Parent:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(walkanim)
script.Parent:WaitForChild("Humanoid").Running:Connect(function()
	if not walk.IsPlaying then
		walk:Play()
	end
end)

And heres my jumping animation script:

local anim = game.ReplicatedStorage.Animations.Jump
local jump = script.Parent.Humanoid.Animator:LoadAnimation(anim)

script.Parent.Humanoid.Jumping:Connect(function()
        if not jump.IsPlaying then
                jump:Play()
        end
end)

The reason I am showing the jumping animation script is because they’re almost identical and I am very confused as to why the walking won’t work.

Thank you for reading!

2 Likes

Just Checking; Are all of those scripts in StarterCharacter?

These scripts are in StarterCharacterScripts which is located in StarterPlayer.

And these anims are created by you?

I work for a group, so I put all the animations for the group.
It was indeed made by me, but I published it to ROBLOX under the group.

walk anim doesn’t play? or looks wierd?

(Edited)

I appreciate the attempts to help me.

The walking animation does not play.

ok have you tried using the jump anim script and changing it to a walk? or is that on purpose.

Do you mean copying, pasting, and changing the exact script of the jumping script and changing it to a walk script?

This does not work:

local anim = game.ReplicatedStorage.Animations.Walk
local walk = script.Parent.Humanoid.Animator:LoadAnimation(anim)

script.Parent.Humanoid.Running:Connect(function()
	if not walk.IsPlaying then
		walk:Play()
	end
end)

Wait, if you disabled jump script would walk script work? Or would that not make cents

No, that would not make sense.

What I used to do when having custom animations was playing the game in Studio, copy the character’s “Animate” LocalScript, paste it into StarterCharacterScripts and replace the certain AnimationIds with the custom animations.

That is, if all players are supposed to have the same animations though.

1 Like

Use this instead;

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		Character.Animate.walk.WalkAnim.AnimationId = "rbxassetid://--Your Anim ID"
	end)
end)

Script in serverScript
Sorry if Im late…

Can you record a video so I can see why the animation not working?

The humanoid state you are catching with the event, Running, it only fires, when you come from another state, such as falling, landed, getting up, etc…

So most likely your event is not firing.

For walking you need to have a loop, that checks the velocity of your HumanoidRootPart, and if you are in a Running state, and velocity is > or < than a value, play the walk or run or idle animations.