I have a text button that shows the name of the emote in a frame with others and I have a script that makes you able to press on it then you player does the emote. This works but, when I make a looping animation there is no way to stop it. When you click it you do the animation and can't stop even when another is clicked. It looks really weird and people can't stop so I need a script that can make it stop when another emote is clicked or just a stop text button whichever works. Thank you.
The script I use in the text button:
wait(3) Player = game.Players.LocalPlayer.Character animation1 = Player.Humanoid:LoadAnimation(script.Animation1) CanEmote = true
script.Parent.MouseButton1Click:connect(function() local emote = math.random(1,1) if emote == 1 and CanEmote == true then animation1:Play() CanEmote=false wait(2) CanEmote=true end end)
Anything I can do or add?
Hi! There is this property of the Humanoid called GetPlayingAnimationTracks, which returns all animations that are playing into an table. You then use a for loop to go through each one then stop them.
local Player = game.Players.LocalPlayer.Character CanEmote = true animation1 = Player.Humanoid:LoadAnimation(script.Animation1) script.Parent.MouseButton1Click:connect(function() local emote = math.random(1, 1) if (emote == 1) and (CanEmote == true) then CanEmote = false local playing = Player.Humanoid:GetPlayingAnimationTracks() for _, v in pairs (playing) do v:Stop() end animation1:Play() wait(2) CanEmote = true end end)