Hello, I coded a script that checks if there is something in bounds. My issue is for some reason its counting itself as a part in bounds.
Note: Current is a model with lots of parts inside of it and I want it so the script ignores everything inside current.
Here is my code:
local current = script.Parent -- a model
local cframe = current:GetPivot()
local params = OverlapParams.new({current:GetDescendants()},Enum.RaycastFilterType.Blacklist,1,"Default")
local Checker = workspace:GetPartBoundsInBox(cframe, Vector3.new(5,5,5), params)
if #Checker == 0 then
print("Run code")
else
warn("denied request because something was in the way" )
warn(Checker)
end
It always detects something in the way since it detects itself. I can even see it in the
To solve the issue of the script counting itself as part within bounds, you should add a condition to exclude βcurrentβ in the script. For example, you could exclude all parts within βcurrentβ in the creation of βparamsβ using this code:
local current = script.Parent -- a model
local cframe = current:GetPivot()
local children = current:GetChildren()
local exclusions = {}
for i, child in pairs(children) do
table.insert(exclusions, child)
end
local params = OverlapParams.new({exclusions}, Enum.RaycastFilterType.Blacklist, 1, "Default")
local Checker = workspace:GetPartBoundsInBox(cframe, Vector3.new(5,5,5), params)
if #Checker == 0 then
print("Run code")
else
warn("denied request because something was in the way" )
warn(Checker)
end