Im making a chainsaw, where it plays an animation when you equip it, and it stops the animation once you unequipped it. However, the animation only stops when you click! Why is this? CODE:
tool = script.Parent
anim = tool.Animation
attacking = false
tool.Equipped:Connect(function()
local animation = tool.Parent.Humanoid:LoadAnimation(anim)
animation:Play()
tool.Idle:Play()
tool.Activated:Connect(function()
tool.Rev:Play()
tool.Idle:Stop()
attacking = true
tool.Deactivated:Connect(function()
tool.Idle:Play()
tool.Rev:Stop()
attacking = false
tool.Unequipped:Connect(function()
animation:Stop()
tool.Rev:Stop()
tool.Idle:Stop()
end)
end)
end)
end)
tool.Handle.Touched:Connect(function(hit)
if attacking == true then
if hit and hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(50)
tool.Oof:Play()
hit:Destroy()
end
end
end)

3 comments
Still won't work. Plus, it's a sound and not an animation
I edited the answer.
thanks!