How would I accurately detect if a part is inside of another part?

The title explains it. I need to use a script to detect if a part is inside of another. But I don’t know how I would do this. Can anyone help me?

this what you need
https://developer.roblox.com/en-us/api-reference/function/WorldRoot/FindPartsInRegion3

3 Likes

Thank you so much! I was wondering if there was a function for this that I just didn’t know about.

In case anyone wants to know, this is how I figured out the region3 of a part. There’s probabally a better way to find it, but this is what I did.

local topCorner = part.Position + Vector3.new(part.Size.X / 2,part.Size.Y / 2,part.Size.Z / 2)
local bottomCorner = part.Position + Vector3.new(-part.Size.X / 2,-part.Size.Y / 2,-part.Size.Z / 2)
local region3 = Region3.new(bottomCorner, topCorner)
print(workspace:FindPartsInRegion3(region3))

Note the API reference! This element is deprecated. Do not use it for new work.

Is there an alternative method now?

1 Like