Won't print anything in region?

I have no clue what I am doing wrong, it won’t print anything in the region:

function CharacterModule:HitBoxRegion()
	local HixBox = self.Character.HumanoidRootPart.HitBox
	
	local TopLeftFrontOfHitBox = HixBox.Position + Vector3.new(HixBox.Size.X / 2, HixBox.Size.Y / 2 , HixBox.Size.Z / 2)
	local TopRightBackOfHitBox = HixBox.Position + (Vector3.new(HixBox.Size.X / 2, HixBox.Size.Y / 2, HixBox.Size.Z / 2) * -1)
	
	local HitBoxRegion = Region3.new(TopLeftFrontOfHitBox, TopRightBackOfHitBox)
	
	local GetPartsInRegion = workspace:FindPartsInRegion3(HitBoxRegion)
	
	for _, v in pairs(GetPartsInRegion) do 
		print(v.Name)
	end
end
1 Like

Have you tried using workspace:GetBoundsInBox()? I heard the Region3 API stopped working.

You could alternatively use the workspace:GetPartsInPart() function.

GetPartsInPart requires another part to be created by the script, while GetPartBoundsInBox just needs the CFrame and Size, which may be more convenient for OP.

It seems that OP already defined HixBox. workspace:GetPartsInPart(Hixbox)

GetPartBoundsInBox only considers bounding boxes rather than the actual occupied volume, so GetPartsInPart would be much more useful if HixBox is a MeshPart or not a standard block shape.

You don’t have to define CFrames and Regions with GetPartsInPart which would save OP from needing to define it every time. Also GetPartBoundsInBox returns its array faster than GetPartsInPart but at the cost of being less accurate.

So if the HixBox was just a regular part would workspace:GetBoundsInBox() be better?

It depends on the use case and mostly on how frequent it’s being called. If OP’s function is gathering parts within HixBox many times per second and it’s a standard block part, he should use GetPartBoundsInBox since its faster, but could come up with inaccuracies/missed parts if there are fast moving parts or if HixBox is a moving part. GetPartsInPart is slower because it performs a full geometric collision check when called. Because of that it will be much more accurate, especially for moving parts, but it still will not be 100% accurate for moving parts since it takes time to calculate.

Edit: Whoops, I didn’t realize I was responding to OP.

Thank you, that helps me a lot.