How to make :GetPartsBoundsInBox() not have face-to-face contact?

i’m trying to make a building system, when the player tells the server to place an item, the server will first make sure that there isnt any collisions happening:

local collisions = workspace:GetPartBoundsInBox(location, hitbox.Size)

it works, but it keeps returning the baseplate because of the faces are touching, is there a way to make it only return whats “inside” of it?

the only solution i could think of is shrinking the size a little, but i wanted to check if there was a more reliable way beforehand. :GetPartsInPart() works but i wasn’t sure if cloning the part, setting its location, checking for collisions, then destroying it was the best way to go about this.

Someone had similar problem and i made reply:

Just check that part with this function i sent

Would I just use :GetPartBoundsInBox() to get the touching parts, then pass them all through that function to see if they are actually colliding or not? If so, I edited the function a little bit to not take in a outer part, but instead a relativeCFrame and an outerHalf, but it doesn’t seem to work, it’s fixing the issue with the part colliding with the baseplate but I can put objects inside of other objects.

Well yea, the easiest solution is to shrink the size by a small amount (“add a tolerance”).

local tolerance = 0.1 -- how much smaller inside you want

local clampedX = math.max(0, hitbox.Size.X - tolerance)
local clampedY = math.max(0, hitbox.Size.Y - tolerance)
local clampedZ = math.max(0, hitbox.Size.Z - tolerance)

local smallerSize = Vector3.new(clampedX, clampedY, clampedZ)
local collisions = workspace:GetPartBoundsInBox(location, smallerSize)

You can do this in other ways too, but this is easy

Ye that what i meant for you to do.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.