local Flourbag = game.Workspace.Flourbag
local clickDec = game.Workspace.Flourbag.ClickDetector
local Animation = Instance.new("Animation")
Animation.Parent = game.Workspace
Animation.AnimationId = "http://www.roblox.com/asset/?id=5446725528"
local punch = 1
clickDec.MouseClick:Connect(function(Player)
if punch == 1 then
local animTrack = Player.Character.Humanoid:LoadAnimation(Animation)
animTrack:Play()
punch = 2
elseif punch == 2 then
animTrack:Stop() --animTrack is underlined in red for some reason
punch = 1
end
end)
I have the script parented to the flourbag. The animation plays when I click the flourbag but when I click again it doesn't stop. Sorry if my question is stupid as I'm very new to scripting.

5 comments
I'm a little confused, what do I do with the "punch == 2"? Right now nothing works in the script.
oh yes, I totally forgot about it, just remove that if i'll edit the answr
It still doesn't work, it says "attempt to call a nil value" (sorry for the inconvenience)
I edited it again, sorry for the error, I wasn't paying attention when I edited it first time
Thank you!