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.
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.
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.
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.
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.