Help coding swing (broken) and idle (done) animation

This code is from a YouTube tutorial, but it still does not work. When it’s only hold animation, it works, but when I add the swing animation, it breaks both.

Code:

local plr = game:GetService("Players").LocalPlayer
local anims = {script.Parent.Hold, script.Parent.Swing}
local loadedAnims = {}
local tool = script.Parent
local animator
local debounce = true
local del = 5
tool.Equipped:Connect(function(mouse) --On tool equipped do:
	animator = plr.Character:WaitForChild("Humanoid"):WaitForChild("Animator") --Find the animator object
	if not loadedAnims[1] then --If the animation wasn't loaded before
		loadedAnims[1] = animator:LoadAnimation(anims[1]) --Load it
	end
	loadedAnims[1]:Play()	--Play it
	
end)

--Click animation:
tool.Activated:Connect(function()
	if(debounce) then --Setting up the debounce (cooldown)
		debounce = false
		animator = plr.Character:WaitForChild("Humanoid"):WaitForChild("Animator") --Find the animator object
		if(not loadedAnims[2]) then --If the animation didn't exist yet
			loadedAnims[2] = animator:LoadAnimation(anims[2]) --Load it
		end
		loadedAnims[2]:Play() --Play it
		
		wait(del) --Wait the cooldown
		debounce = true
	end
end)

tool.Unequipped:Connect(function()
	loadedAnims[1]:Stop() 
	if(loadedAnims[2]) then 
		loadedAnims[2]:Stop()
	end
end)