I haven’t tested this to see if my method works 100%, however I made it so that it can detect if any part (regardless of rotation) is encompassed by a boundary, using Absolute size of a part - #22 by nicemike40 and @zeuxcg’s code for AABBs

*I also edited the format of it a bit to copy a game I am testing with… …I apologize*

```
local allVectors = {
Vector3.new(0,0,1),
Vector3.new(0,0,-1),
Vector3.new(1,0,0),
Vector3.new(-1,0,0),
Vector3.new(0,1,0),
Vector3.new(0,-1,0)
}
function GetWorldSize(part)
local abs = math.abs
local cf = part.CFrame
local size = part.Size
local sx, sy, sz = size.X, size.Y, size.Z
local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = cf:components()
local wsx = abs(R00) * sx + abs(R01) * sy + abs(R02) * sz
local wsy = abs(R10) * sx + abs(R11) * sy + abs(R12) * sz
local wsz = abs(R20) * sx + abs(R21) * sy + abs(R22) * sz
return Vector3.new(wsx, wsy, wsz)
end
function CheckIfPartIsInsideAnotherPart(boundary, part)
for _, Vector in pairs(allVectors) do
local boundaryGlobalSize = GetWorldSize(boundary)
local partGlobalSize = GetWorldSize(part)
local BaseEnd = boundary.Position + (boundaryGlobalSize * Vector) / 2
local ControlEnd = part.Position + (partGlobalSize * Vector) / 2
local BaseDirection = (boundary.Position - BaseEnd).Unit
local ControlDirection = (BaseEnd - ControlEnd).Unit * BaseDirection
if ControlDirection.X > 0 or ControlDirection.Y > 0 or ControlDirection.Z > 0 then
return false
end
end
return true
end
```