Hello everyone, I’ve come across a problem where the animation does not stop even when there is a :Stop() in the script
local playing = false
local gui = script.Parent.Parent.Parent.DanceGUI
local button = script.Parent.Parent.Parent.Emote
script.Parent.MouseButton1Click:Connect(function()
local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.HipHop)
if playing == false then
gui.Visible = false
button.Visible = true
playing = true
animation:Play()
else
if playing == true then
animation:Stop()
gui.Visible = false
button.Visible = true
playing = false
end
end
end)
Maybe its becuase your loading the animation each time u press the button? and roblox is creating a new value for it instead of keeping the old one. Just a game theory
You can try this, you move the local animation variable out of the mouseclick detector
local playing = false
local gui = script.Parent.Parent.Parent.DanceGUI
local button = script.Parent.Parent.Parent.Emote
---- here
local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.HipHop)
script.Parent.MouseButton1Click:Connect(function()
if playing == false then
gui.Visible = false
button.Visible = true
playing = true
animation:Play()
else
if playing == true then
animation:Stop()
gui.Visible = false
button.Visible = true
playing = false
end
end