I’ve tried to solve the problem by myself since i saw that in the last topic i posted almost nobody replied.
So as i said, i want to stop an animation when playing a different one, otherwise the two animation will override eachother and its required then to click on both animation buttons to stop them.
I’ve tried with
Destroy() and with
Humanoid:GetPlayingAnimationTracks , as @TheCarbyneUniverse told me but none of them worked in the way they’re supossed to (or in the way i want to).
After many tries and ways, i’ve reached this script which seems to look fine, without any errors but it wouldn’t work.
local waving = game.Players.LocalPlayer.PlayerGui.DancesGUI.MainFrame.ScrollingFrame.Waving.DanceButton.Emote local player = game.Players.LocalPlayer local character = player.Character repeat wait() character = player.Character until character local hum = character:WaitForChild("Humanoid") local emote = hum:LoadAnimation(script.Parent.Emote) local emote1 = hum:LoadAnimation(waving) playing = false script.Parent.MouseButton1Click:connect(function() if playing == false then emote1:Stop() emote:Play() hum.WalkSpeed = 0 hum.JumpPower = 0 playing = true elseif playing == true then emote:Stop() hum.WalkSpeed = 16 hum.JumpPower = 50 playing = false end emote1:Stop() end)
The script above is located inside the button of the dance animation GUI, as shown below
The only difference between the two LocalScripts is that the first variable is defined on the other dance’s emote and the
emote1:LoadAnimation(the first variable)
The two animations override eachother. If i click both of them and and then click one of them again, the unclicked animation will continue playing.
Thank you for helping