GetPartBoundsInBox Without Actual Instance

I want to know how to use GetPartBoundsInBox without having an actual instance in the workspace.

	local overlapParams = OverlapParams.new()
	overlapParams.FilterDescendantsInstances = {workspace.Cube2}
	overlapParams.FilterType = Enum.RaycastFilterType.Include
	local touching = workspace:GetPartBoundsInBox(workspace.Cube.CFrame, workspace.Cube.Size, overlapParams)

notice how workspace.Cube exists in the workspace? How do I check using just pure data instead? Does anyone have another method?

1 Like

workspace:GetPartBoundsInBox()

1 Like

Thanks for linking the wiki page. However, please refer to my original post as it doesn’t answer my question.

1 Like

You need to have a variable for the CFrame and Size:

local CheckCubeCF = CFrame.new(0, 5, 0)
local CheckCubeSize = Vector3.one * 4 -- equivalent to `Vector3.new(4, 4, 4)`

Then, pass those in instead:

local touching = workspace:GetPartBoundsInBox(
    CheckCubeCF,
    CheckCubeSize,
    overlapParams
)

The Part does not need to exist in the Workspace. It’s CFrame and Size are just data attached to it.

If you need to use the location and size of the Part, but need to :Destroy the Part, for example, you can do this:

local CheckCubeCF = Cube.CFrame
local CheckCubeSize = Cube.Size

Cube:Destroy()

local touching = workspace:GetPartBoundsInBox(
    CheckCubeCF,
    CheckCubeSize,
    overlapParams
)

, and it will work the same.

1 Like

But you don’t need an Instance?

local parts = workspace:GetPartBoundsInBox(
    CFrame.new(100, 100, 100) * CFrame.Angles(math.rad(45), 0, 0),
    Vector3.new(10, 10, 10)
)
2 Likes

No I mean like detecting other parts in the OverlapParams.FilterDescendantsInstances.

This is where I include the other cube. However, I don’t want to make an instance of it.

1 Like

There are other spatial queries you can use like :GetPartsInBoundBox or :GetPartsInBoundRadius these dont need a instance to get parts inside of.

Edit: nevermind i actually have no idea about what this post is trying to get at

1 Like

If I understand your post correctly you wanted dynamic filter instance?

what I have done before is make a folder then put any part you want to filter in that folder and then include that folder in FilterDescendantsInstances.

here are some example of mine

Explorer:
image

but you can correct me if I misunderstand it

1 Like

I just want to use the filter methods without having an actual part in the workspace. Even a detection algorithm if someone has one would be good.

You can do the same method without parenting the part to the workspace.

local part = Instance.new("Part")

workspace:GetPartBoundsInBox(
    Part.CFrame,
    Part.Size
)

As long as you have the information, it should be all good.

1 Like