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:
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?
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
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```