Can't stop walking animation

  1. What do you want to achieve? Keep it simple and clear!
    I want the walking animation of my character to stop when the jumpscare animation plays.

  2. What is the issue? Include screenshots / videos if possible!
    The walking animation keeps playing even though I scripted it to stop. The walking animation kinda plays as the jumpscare animation plays

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried messing around with the animation priorities. No other problems seems to match mine

Script:
while true do
wait(1)
script.Parent:WaitForChild(“Humanoid”):LoadAnimation(script:WaitForChild(“Animation2”)):Play()
wait(5)
script.Parent:WaitForChild(“Humanoid”):LoadAnimation(script:WaitForChild(“Animation2”)):Stop()
script.Parent:WaitForChild(“Humanoid”):LoadAnimation(script:WaitForChild(“Animation3”)):Play()
end

3 Likes

Remember, you are using a loop, no matter what, it will repeat unless stopped

Here is a possible fix:

local Hum = script.Parent:FindFirstChild("Humanoid")
local A2 = Hum:LoadAnimation(script.Animation2)
local A3 = Hum:LoadAnimation(script.Animation3)

While true do
wait(1)
A2:Play()
Wait(5)
A2:Stop()
A3:Play()

2 Likes

You’re working on a horror game?

2 Likes

I am trying stop the animation. Animation2 is the walk animation and Animation3 is the jumpscare animation. I just don’t know how to fix this.

1 Like

Yes, I’m making a piggy fangame.

2 Likes

The animation is inside a while true script. After Animation3 Plays, it immediately goes back to wait(1) and then replays Animation2.
EDIT: Just reread what you mean, you should use Humanoid.Animator to load animations. After that, you can use Animator:GetPlayingAnimationTracks() to get a table containing all playing animations and just stop them.

2 Likes

Cool ! When it will be finish, please send me a link to the game :slight_smile:

@Gody09gody

Here is a possible Solution for it.

1 Like

I know, It’s just that right when the jumpscare plays, the walking animation doesn’t stop when I tell it to.

1 Like

Check if the animations are looped,then try my solution

1 Like

animation 2 is looped and animation 3 is not looped

2 Likes

And the solution doesn’t work, it just says this in the output: Unable to cast value to object

2 Likes

I see my mistake, add script. Animation2 / Animation3
I fixed the post so it includes it

1 Like

It worked! Thanks for helping me!

2 Likes

No Problem my friend, have a great day!

1 Like

“Did You choosed the wrong post? I understood, you chose the great post.”

No it worked fine. There was some minor errors such as not an “end” to close the while loop and “While” with capital w.

1 Like

No, it’s “(post deleted by author)”. But yes, I’m french so I do mistakes :slight_smile:

@EliottENAnnoucement Spricht Du Deutsch?

Ich bin nicht gut deutsch spricht. (Translation : I am not very good at speaking german. Maybe it don’t would say anything. lol I’m bad at speaking english AND german. French is easier. ^^)