--//Controller//--

Tool.Activated:Connect(function()
	if not Settings.OnCD then
		Settings.OnCD = true
		
		local Hitbox = Tool.Hitbox:Clone()
		Hitbox.Parent = Tool
		
		Debris:AddItem(Hitbox, 0.5)
		
		Swing:Play()
		
		Hitbox.Touched:Connect(function(Hit)			
			local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
			
			if Humanoid then
				if not table.find(DamageBlacklist, Humanoid) then
					table.insert(DamageBlacklist, Humanoid)
					
					DamageEvent:FireServer(Humanoid, Settings.Damage)
				
					task.wait(Settings.CDTime)
					
					if Humanoid then
						table.remove(DamageBlacklist, table.find(DamageBlacklist, Humanoid))
					end
					
				end
			else
				local HealthValue = Hit:FindFirstChildOfClass("IntValue") or Hit:FindFirstChildOfClass("NumberValue")
				
				if HealthValue then					
					if not table.find(DamageBlacklist, HealthValue) then
						table.insert(DamageBlacklist, HealthValue)
						
						DamageEvent:FireServer(HealthValue, Settings.Damage)

						task.wait(Settings.CDTime)

						if HealthValue then
							table.remove(DamageBlacklist, table.find(DamageBlacklist, HealthValue))
						end

					end
					
				end
			end
			
		end)
		
		task.wait(Settings.CDTime)
		
		Settings.OnCD = false
	end
end)
