I am attempting to make my own animation GUI, and the animation wont stop when you press the button again, even though the print is playing.
local plr = game.Players.LocalPlayer
local count = 0
for _,Buttons in pairs(script.Parent:GetChildren()) do
if Buttons:IsA("TextButton") then
Buttons.MouseButton1Click:Connect(function()
local Animation = Buttons.Name
local Replicated = game.ReplicatedStorage.Animations
if Replicated:FindFirstChild(Animation) then
local Animator = plr.Character.Humanoid.Animator
local play = Animator:LoadAnimation(game.ReplicatedStorage.Animations:FindFirstChild(Animation))
if count == 0 then
print("Animation Loaded")
count = count + 1
play:Play()
elseif count == 1 then
count = 0
play:Stop()
print("Animation Stopped.")
end
end
end)
end
end