--- RUNTIME ---


local Tool = {}

Tool.MouseButton1 = function(Character)
	if Character:GetAttribute("Cooldown") == true then return end
	Character:SetAttribute("Cooldown", true)
	
	local Tool = Character[script.Name]
	
	local Animation = Character.Humanoid:LoadAnimation(script["Animation"..AnimationStep])
	AnimationStep += 1
	
	if AnimationStep >= 3 then
		AnimationStep = 1
	end
	
	Animation:Play()
	
	local OGWalkSpeed = Character.Humanoid.WalkSpeed
	Character.Humanoid.WalkSpeed = 0

	Tool.Handle.Swing:Play()

	task.wait(0.47)
	
	local ConnectionA = nil
	Tool.Handle.Touched:Connect(function(Hit)
		if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= Character and not table.find(HitEntities, Hit.Parent) and Hit.Parent.Parent == workspace.Enemies then

			table.insert(HitEntities, Hit.Parent)
			
				Tool.Handle.Hit:Play()
				
				Hit.Parent.Humanoid:TakeDamage(35)
				
				local boopyve = Instance.new("BodyVelocity")
				boopyve.Velocity = Character.Torso.CFrame.LookVector * 5
				boopyve.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
				boopyve.Parent = Hit.Parent.HumanoidRootPart
				game.Debris:AddItem(boopyve, .15)
			
		end
	end)
	
	task.wait(0.43)
	
	Animation:Stop(.25)
	
	Character.Humanoid.WalkSpeed = OGWalkSpeed
	
	Character:SetAttribute("Cooldown", false)
	
	table.clear(HitEntities)
end



return Tool
