Why use WorldRoot?
Spatial queries help implement detection zones without attaching a Touched event to every object. GetPartBoundsInBox checks bounding boxes, so it is a broad query rather than an exact shape intersection test.
Try it in Roblox Studio
Put this Script in ServerScriptService in a Studio place containing Parts around the origin. Change the box size to see how the returned candidates change.
Syntax
workspace:GetPartBoundsInBox(CFrame.new(0, 5, 0), Vector3.new(20, 10, 20), params)Examples
Workspace spatial queries
List parts whose bounding boxes overlap a central region.
local params = OverlapParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {}
local parts = workspace:GetPartBoundsInBox(
CFrame.new(0, 5, 0),
Vector3.new(20, 10, 20),
params
)
for _, part in parts do
print(part:GetFullName())
end- CFrame sets the box center and orientation; Vector3 sets its size in studs.
- OverlapParams can filter descendants, collision groups and result count. The empty exclusion list leaves all candidate parts eligible.
- The returned BaseParts have bounding boxes overlapping the query box; do additional checks if exact geometry matters.
Best practices
- Filter out irrelevant descendants when querying frequently.
- Do not assume bounding-box overlap proves two detailed shapes touch.
Runtime & versions
Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.
Luau documentation