GetPartsBoundInBox() only hitting one humanoid

I’m using GetPartsBoundInBox() and it only seems to hit one humanoid. Here’s a shortened version of the code:

	local getPartsBound = workspace:GetPartBoundsInBox(targetCFrame, targetSize, overlap)
	local alreadyHit = {}
	for i,v in pairs(getPartsBound) do
		if v:IsA("BasePart") and v.Parent:FindFirstChild("Humanoid") then
			if v.Parent:FindFirstChild("Humanoid") and v:IsDescendantOf(workspace.TrainingZones) == false then
				if table.find(alreadyHit, v.Parent) then return end
				if v.Parent:IsDescendantOf(workspace.NPCS) or v.Parent:GetAttribute("Hyperarmour") == true then return end
				local enemyHumanoid = v.Parent:FindFirstChild("Humanoid")
				local enemyRoot = v.Parent:FindFirstChild("HumanoidRootPart")

				table.insert(alreadyHit, v.Parent)
				--damage code has been removed because too long

I’ve tried remove the table.insert and it still only hits one humanoid. Why is this?

1 Like

Im pretty sure its because when you check if v.Parent is already in the table you return the whole function instead of continuing the loop. Try replacing return with continue.

1 Like

Sorry for the late reply, I will try this.

Thank you so much! It works now!! :smile: