How do you check if a part’s completely inside a boundary?

How do you check if a part’s completely inside a boundary?

EG:

local A = workspace.Part
local B = workspace.Bound
if A:IsCompletelyInside(B) then
----
end

I only found one matching topic, and it seemed to be designed for more complex models.

local function IsBoundBy(Part1, Part2)
	return (Part1.Position.X + Part1.Size.X / 2 < Part2.Position.X + Part2.Size.X / 2) and (Part1.Position.Y + Part1.Size.Y / 2 < Part2.Position.Y + Part2.Size.Y / 2) and (Part1.Position.Z + Part1.Size.Z / 2 < Part2.Position.Z + Part2.Size.Z / 2)
end

local Part1, Part2 = Instance.new("Part"), Instance.new("Part")
Part1.Size = Vector3.new(2, 2, 2)
Part2.Size = Vector3.new(3, 3, 3)

print(IsBoundBy(Part1, Part2)) --true
Part2.Size = Vector3.new(1, 1, 1)
print(IsBoundBy(Part1, Part2)) --false
3 Likes