I have a gui with multiple emote buttons in them. A, B, and C for example. When button A is pressed, Emote A will play. When Button A is pressed again, Then Emote A Stops. However, if button A is pressed, And Emote A is playing, if Button B is pressed, Emote B will start playing while Emote A is still playing in the background. So if Button B is pressed again, Emote B will stop and Emote A will still be playing in the background.
My Goal is to have All other animations to stop if one button is pressed.
This is the script inside of each Emote Button
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)
playing = false
script.Parent.MouseButton1Click:connect(function()
if playing == false then
emote:Play()
hum.WalkSpeed = 16
hum.JumpPower = 50
playing = true
elseif playing == true then
emote:Stop()
hum.WalkSpeed = 16
hum.JumpPower = 50
playing = false
end
end)
The Animation is placed within the button along with the local script above
Sorry if my explaining is terrible

1 comment
I think it better to make a BoolValue in the Character as a debounce.