The animation won't stop once played, I have it set too Loop and also Action as the priority. Any help would be appreciated.

local debounce = false
local tool = script.Parent
local Animations = script.Parent.Animations

function Equipped()
	local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Animations.SwordIdle)
	animation:Play()
end

function Unequipped()
	local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Animations.SwordIdle)
	tool.Unequipped:Connect(function()
	animation:Stop()
	end)
end

function Swing()
	local animation1 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Animations.SwordSwing)
	local animation2 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Animations.SwordIdle)

if not debounce then 
	
	debounce = true
	animation2:Stop()
	animation1:Play()
	
	debounce = false
	end
end

function swordhit(hit)
end


tool.Equipped:Connect(Equipped)
tool.Unequipped:Connect(Unequipped)
tool.Activated:Connect(Swing)
tool:FindFirstChild("Handle").Touched:Connect(swordhit)