My walking animation won't 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.

Both scripts are located in StarterCharacterScripts and are LocalScripts.
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!

1 Like

Try replace waitforchild with FindFirstChild in the walk script

1 Like

This sady does not work. Thanks for being the only response though.

1 Like

Can you try doing simple debugging by adding a print statement in the Running listener?

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

This won’t change anything but it’ll help bring us a step closer to finding the issue- which is seeing if the Running event is firing for your custom character.

Let us know if Running gets printed in the Output Window as your speed changes.

Is your game a group game? Because animations that aren’t default Roblox animations don’t work in group games. But there is a solution to that problem by using scripts and welds or motor6d.

I’ll try printing it, thanks for the response.

Yes, this is a group game.
However, I published the animation under the group, so it should work. That’s why the jumping animation works.

idk why the jump anim works but for me it wont work even if its published under the group I had the same problem as you I can give you the script I used to do a pose.

Screen Shot 2022-08-14 at 9.26.08 PM
This is what the output says, but the animation is not playing.
Oops, forgot to show the script:

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

script.Parent.Humanoid.Running:Connect(function()
	print("walking detected")
	if not walk.IsPlaying then
		print("is playing hopefully")
		walk:Play()
	end
end)

That’s really strange considering all of the other animations are working properly.
Are you sure you’ve got the correct walking animation ID setup, with the correct priority, keyframes, etc?

If you’re already sure of that, try implementing the walking animation like this:

humanoid.StateChanged:Connect(function(_, new)
    if new == Enum.HumanoidStateType.Running then
        walkingAnim:Play()
    else
        walkingAnim:Stop()
        -- Ideally you'd play your idle animation here (not necessary)
    end
end)

Alright, I fixed the problem with the animation, and I tried your script, but the animation keeps repeating for some reason, I only have one script for the walking, and I changed it to yours, so I don’t know why it’s repeating.

Screen Shot 2022-08-15 at 7.33.33 AM
Ok, so I made it so that the new thingy is printed everytime the state changes and, this is what came out.

It seems like the running state starts whenever I am on a surface, and not Idle, for some reason.
Does anybody know why this could be happening?

Enum.HumanoidStateType.Running does not necessarily mean you are ‘running’ it also means you are idle, or walking. It is pretty much the state you are in when on a surface.

Would I put if script.Parent.Humanoid.WalkSpeed > 0.01 then after it checks if its in a Running state then?

or you can check humanoid.movedirection

if not script.Parent.Humanoid.MoveDirection == Vector3.new(0,0,0) then

Like this?

script.Parent.Humanoid.MoveDirection.Magnitude > 0 then

For some reason this only works when I jump and then walk. Also it still does it when im idle.

can you show what your code currently looks like?

also, are all the animaions at least playing, its just they are not playing in the correct way?