I need help with my hitbox module

local GoodSignal = require(script.GoodSignal)

local MaxHitbox = {}
MaxHitbox.__index = MaxHitbox

MaxHitbox.DebugColor = Color3.fromRGB(255, 0, 4)
MaxHitbox.DebugTransparency = .2
MaxHitbox.DebugMaterial = Enum.Material.ForceField


function MaxHitbox.CreateHitbox(params : {})
	local self = setmetatable({}, MaxHitbox)

	self._Params = params
	self._Box = nil
	self._RunServiceHeartbeat = nil

	self._Visualizer = params.Visualizer or false

	self._Size = params.Size or Vector3.one
	self._TouchMode = params.TouchMode or "Humanoid"
	self._Mode = params.Mode or "Default"
	self._CFrame = params.CFrame or CFrame.new(5,5,5)
	self._DebounceTime = params.DebounceTime or 0
	self._Lifetime = params.Debris or 0
	self._UseClient = params.Client or nil

	self._PartWeld = nil
	self._PartWeldOffset = CFrame.new(0,0,0)

	self._Blacklist = params.Blacklist or {}
	self._CharsList = {}
	self._ObjectsList = {}

	self.Touched = GoodSignal.new()
	self.HumanoidTouched = GoodSignal.new()

	self._OverlapParams = OverlapParams.new()
	self._OverlapParams.FilterDescendantsInstances = self._Blacklist
	self._OverlapParams.FilterType = Enum.RaycastFilterType.Exclude


	return self
end

function MaxHitbox:_Visualize()
	if not self._Visualizer then return end
	if not self._Box then
		self._Box = Instance.new("Part")
		self._Box.Size = self._Size
		self._Box.Material = self.DebugMaterial
		self._Box.CFrame = self._CFrame
		self._Box.Color = self.DebugColor
		self._Box.Transparency = self.DebugTransparency
		self._Box.CanCollide = false
		self._Box.CanQuery = false
		self._Box.Parent = workspace.Terrain
		self._Box.Anchored = true

	else
		self._Box.CFrame = self._CFrame
	end
end

function MaxHitbox:_CheckForHumanoids(model : Model)


	if not table.find(self._CharsList, model) then

		table.insert(self._CharsList, model)
	end



	for i, object : Model in self._CharsList do
		self.HumanoidTouched:Fire(object, object.Humanoid)
	end

	table.clear(self._CharsList)
end

function MaxHitbox:_CheckForObjects(v : any)
	if not table.find(self._ObjectsList, v) then
		table.insert(self._ObjectsList, v)
	end

	for i, object in self._ObjectsList do
		self.Touched:Fire(object)
	end
end

function MaxHitbox:_ClearConnections()
	for i, connection in self._Connections do
		print( connection)
		connection:Disconnect()
		connection = nil
	end
end

function MaxHitbox:WeldTo(Part, CFrame)

	self._PartWeld = Part

	if CFrame then
		self._PartWeldOffset = CFrame
	end
end

function MaxHitbox:_Cast()
	local CanHit = true


	self._RunServiceHeartbeat = game:GetService("RunService").Heartbeat:Connect(function()

		if self._PartWeld then
			self._CFrame = self._PartWeld.CFrame * self._PartWeldOffset
		end

		local result = workspace:GetPartBoundsInBox(self._CFrame, self._Size, self._OverlapParams)

		self:_Visualize()

		for i,v in pairs(result) do

			local model = v:FindFirstAncestorWhichIsA("Model") or v.Parent

			if not model:IsA("Model") then continue end

			if self._Mode == "Default" then
				if self._TouchMode == "Humanoid" then

					if not CanHit then return end


					self:_CheckForHumanoids(model)

					CanHit = false

					break

				elseif self._TouchMode == "Object" then

					if not CanHit then return end


					self:_CheckForObjects(v)


					CanHit = false

					break

				elseif self._TouchMode == "Both" then

					if not CanHit then return end

					self:_CheckForHumanoids(model)
					self:_CheckForObjects(v)


					CanHit = false

					break
				end

			elseif self._Mode == "ConstantDetection" then
				if self._TouchMode == "Humanoid" then


					if not CanHit then return end


					self:_CheckForHumanoids(model)


					if self._DebounceTime then
						CanHit = false

						task.delay(self._DebounceTime, function()
							CanHit = true
						end)

					end

				elseif self._TouchMode == "Object" then

					if not CanHit then return end


					self:_CheckForObjects(v)

					if self._DebounceTime then
						CanHit = false

						task.delay(self._DebounceTime, function()
							CanHit = true
						end)

					end

				elseif self._TouchMode == "Both" then

					if not CanHit then return end


					self:_CheckForHumanoids(model)
					self:_CheckForObjects(v)

					if self._DebounceTime then
						CanHit = false

						task.delay(self._DebounceTime, function()
							CanHit = true
						end)

					end
				end

			elseif self._Mode == "DestroyOnHit" then

				if self._TouchMode == "Humanoid" then

					if not CanHit then return end

					self:_CheckForHumanoids(model)

					CanHit = false

					self:Stop()

					break

				elseif self._TouchMode == "Object" then

					if not CanHit then return end


					self:_CheckForObjects(v)


					CanHit = false

					self:Stop()

					break

				elseif self._TouchMode == "Both" then

					if not CanHit then return end

					self:_CheckForHumanoids(model)
					self:_CheckForObjects(v)


					CanHit = false

					self:Stop()

					break

				end

			end


		end
	end)
end

function MaxHitbox:Start()


	self:_Cast()


	if self._Lifetime > 0 then


		task.delay(self._Lifetime, function()
			self:Stop()
		end)
	end
end


function MaxHitbox:Stop()


	if self._RunServiceHeartbeat then

		self._RunServiceHeartbeat:Disconnect()
		self._RunServiceHeartbeat = nil

	end

	table.clear(self._CharsList)
	table.clear(self._ObjectsList)

	if self._Box then
		self._Box:Destroy()
		self._Box = nil
	end

	self.HumanoidTouched:DisconnectAll()
	self.Touched:DisconnectAll()

	setmetatable(self, nil)
end


return MaxHitbox

I need help with my module. It only detects one humanoid and can’t detect more than one unless the hitbox is moved. Pls I need help :sob:

First #help-and-feedback:scripting-support and #scripting

Why not just clone the hitbox?

Though I don’t know how you would implement this in a metatable, you need to switch to .Touched() to any other method of hit registration. Magnitude, raycasts, partsinbox, anything but touched. I have a guide here.