Can't stop animation?

After stopped, the IsPlaying bool is false but the animation continues to play.

2 Likes

Was it looped in the Animation Editor? I had a similar problem where I accidentally left the Looped property on in there and it wouldn’t stop, even if I called :Stop().

3 Likes

I tried manually disabling the Looped property through scripting though, also the animation is supposed to be looped.

1 Like

From wiki

  1. The first argument is simply the time roblox takes to interpolate from the playing animation’s pose to the default/next-in-priority animation’s next pose. Setting it to 0 simply means you wish for no interpolation and the character to instantly continue doing other animations. Passing in more than one argument does nothing at all.
  2. 0 is considered a successful execution (in OS processes, let’s ignore the fact that this has absolutely nothing to do with Lua). Which means it would be a return value after the function finished executing. How would passing the return code as an argument influence the function… to work successfully?
  3. Stop is a void by Roblox definition. It won’t ever return anything and the only thing it can do to influence program execution is to throw an error. It does not have a return code, and it does not tell you if it worked successfully (unless it errors, in which case it didn’t).
5 Likes

Can you try doing print(Animations.pose1.IsPlaying) right before and right after the Stop line?

4 Likes

This is what I did:

		elseif posing == true and isAttacking == false then
			print("s")
			posing = false
			
			print(Animations.posel.IsPlaying)
			
			wait(0.5)
--			Animations.pose:Stop()
--			Animations.spose:Stop()
			Animations.posel:Stop()
			Animations.sposel:Stop()
			
			print(Animations.posel.IsPlaying)
		end
	end
end)

This is the output:

2 Likes

The track you’re trying to stop isn’t playing anymore at that point. A different animation track is causing issues. You can try the same printing procedure with spose1 to verify that that is not the track either. Regardless, it would really help if you told us which of your 5 tracks is playing when it shouldn’t be.

One possible reason is that your Animation instances have the wrong IDs.

3 Likes

Sorry for not stating it obvious. After triggering the function, it checks if posing is false and isAttacking is false (These works fine), then afterwards it’ll play “pose” and “spose” then afterwards it play “posel” and “sposel” (l stands for loop).
If did correctly, the outcome will look like this:


(The first time I wasn’t including pictures because I didn’t want to leak, but now I understand it is needed.)

And now, pose and spose already ended so it wasn’t needed anymore, so the only animations I need to stop are “posel” and “sposel” which both are supposed to looped.

And now the posing variable is true, once triggered again the function will stops “posel” and “spsoel” which both didn’t stop and that’s how this topic was made.

2 Likes

That makes more sense. I wouldn’t know why your code segment doesn’t work then (except that 100% verify and double check that all animation IDs and variable names match).

One thing to note is that it’s not needed to have a pose entry and a pose loop animation if the pose loop animation is a single, still pose. You can call track:AdjustSpeed(0) to freeze the pose entry animation at any point in time, then either Stop or AdjustSpeed(1) to go out of pose.

4 Likes

I’ll have a try, thanks for your tips.

2 Likes

It still did not work, I absolutely have no idea why now.

3 Likes

How/when are you calling the function? It might execute too often in which case the wait()s can mess up the timing. Try commenting them out.

Edit: I should note this is a debug fix and will cause unwanted behavior. If this ends up being the actual issue, you will need a different code

3 Likes

You could maybe try waiting for the “pose” and “spose” animations to finish (With “animation.Ended:Wait()”) and :Stop() them before starting the “poseI” and “sposeI” animations. It looks like your idle loop animations never play and the character is just stuck in a position.

4 Likes

The function is called upon the player pressing G, I haven’t set a cooldown yet but I didn’t press them rapidly.

2 Likes

“pose” and “spose” are higher animation priority than posel and sposel so it’s completely fine to call these two way before pose and spose ends. Also pose and spose are just “roll in” animation for posel and sposel (Which isn’t looped of course) if you’ve seen the gif I’ve listed in a reply before yours.

I can attach a gif including the only “pose” and “spose” to show how it works, since English isn’t my native language I ended up making mistakes on my explanations so I’m sorry.

3 Likes

That gif would be helpful.

Acoording to this output the poseI animation has already stopped playing before you :Stop() it. Is this what you want?

2 Likes

According to the output, yes it has been indeed stopped. But on screen it is not, the animation is stopped but the player’s pose is still the animation. That’s the problem, I can send gif if you want.

2 Likes

This might’ve been a Roblox glitch since in my other games the :Stop() works, but not in the place I use to work on this pose thing. I might try and move everything in this game to a new place instead and if the error is still occuring, I might aswell have to discontinue this project. Thank you for all the helps.

4 Likes

After almost a year later, I have finally came up with a solution.

The animation playing script was server-sided (the script stated in topic post), triggered by LocalScripts, because I believe animations played locally would not play for other players, which I later found wrong. The issue about the script is that it loads new animations every time it is called, thus making it does not stop the animation playing, instead it stops the new one that was loaded in which it wasn’t even played yet. I later rewrote the script, playing animations in LocalScript (which actually plays the animation for other players somehow) and other server-sided tricks goes into the server-sided script, which makes the animation playing no longer an issue.

The game has been resurrected now. I appreciate all the attempts to help in the past, it is purely my fault for I did not state the problem and everything clear. I hope this bump can help new scripters somehow.

22 Likes

Thank you for sharing this even after a year. I had never figured this out if it wasnt for you😘

1 Like