--[ Variables ]--
local IdleAnimation = script.Idle
local Attack1Animation = script.Attack1
local Attack2Animation = script.Attack2
local randomattack = 0
local player = script:FindFirstAncestorWhichIsA"Player" or game:GetService"Players":GetPlayerFromCharacter(script.Parent.Parent)


--[ Animation Triggers ]--

function IdleAnimationTrigger()
	local humanoid = player.Character.Humanoid
	local IdleAnimationLoad = humanoid:LoadAnimation(IdleAnimation)
	IdleAnimationLoad:Play()
end

function IdleAnimationStoppingTrigger()
	local humanoid = player.Character.Humanoid
	local IdleAnimationLoad = humanoid:LoadAnimation(IdleAnimation)
	IdleAnimationLoad:Stop()
end

function Attack1AnimationTrigger()
	local humanoid = player.Character.Humanoid
	local Attack1AnimationLoad = humanoid:LoadAnimation(Attack1Animation)
	Attack1AnimationLoad:Play()
end

function Attack2AnimationTrigger()
	local humanoid = player.Character.Humanoid
	local Attack2AnimationLoad = humanoid:LoadAnimation(Attack2Animation)
	Attack2AnimationLoad:Play()
end

--[ Attack Scripts ]--
script.Parent.Parent.Equipped:Connect(function(mouse)
	while true do
		IdleAnimationTrigger()
		if mouse.Button1Down then
			IdleAnimationStoppingTrigger()
			local randomattack = math.random(1,2)
			if randomattack == 1 then
				Attack1AnimationTrigger()
			end
			if randomattack == 2 then
				Attack2AnimationTrigger()
			end
			script.Parent.Touched:Connect(function(hit)
				if hit:FindFirstChild("Humanoid") then
					hit.Humanoid.Health:Damage(2.5)
					hit.Humanoid.Sit = true
				end
				IdleAnimationTrigger()
			end)
		end
		if script.Parent.Parent.Unequipped then
			IdleAnimationStoppingTrigger()
			break
		end
	end
end)


This script is inside of a tool, inside of a union called Stunner. Multiple things are happening. Two things I know are going wrong are (I don't know why they are happening), The attack animation is repeating over and over and it's not stopping when I de-equip (along with the idle :/).

##Can anyone bust this myth?

Sincerely,

Narwhal