This is my script and when I unequip the tool, it doesn’t interrupt the animation or the sound.
does anyone know a better way to interrupt the animation and sound when unequipped?
local tool = script.Parent
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://7155654999"
local Anim2 = Instance.new("Animation")
Anim2.AnimationId = "rbxassetid://7155762522"
local sound = tool.Handle.Sound
sound.Looped = false
local track
local track2
tool.Equipped:Connect(function()
track = script.Parent.Parent.Humanoid:LoadAnimation(Anim)
track.Priority = Enum.AnimationPriority.Action
track.Looped = true
track:Play()
end)
tool.Activated:Connect(function()
track2 = script.Parent.Parent.Humanoid:LoadAnimation(Anim2)
track2.Priority = Enum.AnimationPriority.Action
track2.Looped = false
track2:Play()
sound:Play()
end)
tool.Unequipped:Connect(function()
if track then
track:Stop()
elseif track2 then
track2:Stop()
elseif sound then
sound:Stop()
end
end)