When I click one of my emote gui then click on another one the other can still be played if unnequipped

When I click for example “Levitation”, then I click to “Cry” and when I try to click cry again it unequips but then the levitation is still there, how do I fix this issue.
image
image

1 Like

Have you tried waiting for animation to stop playing after you issued Stop()?

I don’t understand what you’re trying to say, can you send a video of it not working as intended?

https://www.roblox.com/games/6086284454/Japan-Vibe-District Go visit the game and just click on the emotes but don’t click it twice tho you’ll see what I’m talking about

https://www.roblox.com/games/6086284454/Japan-Vibe-District Go visit the game and just look if my script has something wrong in it that is making this issue.

You could do something like this. I haven’t tested it in studio, just whipped it up quickly.

local humanoid = game.Players.LocalPlayer.Character.Humanoid
local activeAnimations = humanoid:GetPlayingAnimationTracks()
for _,v in pairs(ActiveTracks) do
v:Stop()
end

I mean by what I understand this isn’t really an issue, as you first need to click Levitation again since it’s still equipped. However, if you really want we can come up with a solution to this.

When you stop the animation in line 15, make sure you loop through each playing emote
using:

local PlayingAnimations = Humanoid:GetPlayingAnimationTracks()

What the above function basically does is that it gets the current tracks that are playing on the humanoid, now I don’t want you to stop every single animation as of course its going to also stop the idle and walking animations and the normal Roblox animations. So what you should do instead is contain all your custom emote animation ids in a table, and then loop through each of those and compare it with the values of the playing animation tracks, if it matches then you can simple stop it with v:Stop().

Please note that it is preferable to keep the table with all the animation ids in a module script and that a way you could compare both the values of the emotes and playing animation tracks is by looping through the playing animation tracks and then within that for loop you could use another for loop to loop through the module script’s table. Now what that would do is, for each of the playing animation tracks it would loop through the table filled with the animation ids and then you could use if statements to determine whether or not the playing animation tracks match up with the ids of the table, and if they do you stop them.

If you need help free free to DM me!