Attempting to get parts INSIDE another part, not touching parts

I’m attempting to make a furniture system, and I’m using GetPartsBoundInBox to get parts inside the model’s primary part.

Function
function PartsInModel()
	local Params = OverlapParams.new()
	Params.FilterDescendantsInstances = {Model}
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	
	local Parts = workspace:GetPartBoundsInBox(Model.PrimaryPart.CFrame, Model.PrimaryPart.Size, Params)
	
	if #Parts > 0 then
		return true
	else
		return false
	end
end

While this works, it also gets parts that are just touching the model’s primary part. For example:
image

While I can ignore the floor, I can’t ignore the walls. I had it set to ignore the floor, and if I placed it away from the wall it worked.

My question is, how can I make it ignore parts that are only touching, and only get the parts that conflict inside the model’s primarypart?

make a region3 with the model:GetBoundingBox

Do you mean FindPartsInRegion3? If so, that function is deprecated. I try not to use deprecated functions in my work.

Is there an updated function that is not deprecated, or is this the only option?

local cf,size = model:GetBoundingBox()
local RegionFromPart = Region3.new(cf.Position- size/2, cf.Position + size/2)
print(#workspace:FindPartsInRegion3WithWhiteList(RegionFromPart,{}))

image

function PartsInModel()
	--[[
	local Params = OverlapParams.new()
	Params.FilterDescendantsInstances = {Model}
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	
	local Parts = workspace:GetPartBoundsInBox(Model.PrimaryPart.CFrame, Model.PrimaryPart.Size, Params)
	
	if #Parts > 0 then
		return true
	else
		return false
	end
	]]--
	
	local IgnoreList = {Model}
	local Region = Region3.new(Model.PrimaryPart.CFrame.Position - Model.PrimaryPart.Size/2, Model.PrimaryPart.CFrame.Position + Model.PrimaryPart.Size/2)
	local Parts = workspace:FindPartsInRegion3WithIgnoreList(Region, IgnoreList)
	if #Parts > 0 then
		for i,v in pairs(Parts) do
			print(v.Name)
		end
		return true
	else
		return false
	end
end

try moving the position Y up by 2 I think it’s still technically counting the floor as in it

I ended up figuring out a solution to my own issue. I’m posting it here just incase anybody else could use the help:

What did I do?
I basically just shrinked the size of the PrimaryPart’s bounding box on all sides by 0.1. Since I snap furniture to a grid, this minor size difference doesn’t matter. You can reduce it smaller than 0.1 if you wanted.

Code:
function PartsInModel()
	local Params = OverlapParams.new()
	Params.FilterDescendantsInstances = {Model}
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	
	local Parts = workspace:GetPartBoundsInBox(Model.PrimaryPart.CFrame, Model.PrimaryPart.Size + Vector3.new(-0.1, -0.1, -0.1), Params)
	
	if #Parts > 0 then
		return true
	else
		return false
	end
end```

image

2 Likes