im having a problem with the equip animation still playing while the tool is already destroyed
local Tool = script.Parent
local humanoid = nil
local drinker = nil
local con = nil
local enabled = false
local db = false
local tool = script.Parent
local anim = Instance.new(“Animation”)
anim.AnimationId = “http://www.roblox.com/Asset?ID=17590050707”
local track
tool.Equipped:Connect(function()
track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
track.Priority = Enum.AnimationPriority.Action
track.Looped = true
track:Play()
end)
tool.Unequipped:Connect(function()
if track then
track:Stop()
end
end)
function onEquipped(mouse)
humanoid = Tool.Parent:FindFirstChild(“Humanoid”)
if humanoid ~= nil then
con = mouse.Button1Down:connect(function() onButton1Down(mouse) end)
drinker = humanoid:LoadAnimation(Tool.anim)
end
end
function onUnequipped(mouse)
humanoid = nil
if drinker ~= nil then
drinker:remove()
drinker = nil
end
if con ~= nil then
con:disconnect()
end
end
function onButton1Down(mouse)
if enabled then
return
end
enabled = true
drinker:Play()
task.wait(1)
enabled = false
end
Tool.Equipped:connect(onEquipped)
Tool.Unequipped:connect(onUnequipped)