OverlapParams.new() doesn't work or respect the parameters I've given

Recently the new OverlapParams API was introduced in this post. I was extremely excited at first to implement this into my game, however I ran into a major hurdle: OverlapParams.new() was not working as intended.

At first I thought it was a parameter formatting issue, but I double checked and tried BOTH the robloxapi.github.io and the original post’s format, and none of them worked.

Instead of whitelisting and only filtering the one part I’ve given, it entirely resorts to the default parameters.

Basic replication of my problem:

local boundBox = workspace.BoundBox
local whitelistPart = workspace.WhitelistPart -- Is inside of boundBox

-- NOTE: There's also a R15 dummy inside the BoundBox, which isn't whitelisted.

-- Despite giving the proper parameters for OverlapParams.new() (trying BOTH the
-- robloxapi.github.io and the Announcement format), none of them work:
local ovParams = OverlapParams.new({whitelistPart}, Enum.RaycastFilterType.Whitelist, 1, "Default") -- Announcement Format 
--OverlapParams.new(1, "Default", {whitelistPart}) -- robloxapi.github.io format


while true do
	wait(3)
	local boundBoxResult = workspace:GetPartBoundsInBox(boundBox.CFrame, boundBox.Size, ovParams)
	
	-- Output is supposed to be "1", boundBoxResult should only include the
    -- whitelistPart, but ends up returning a bunch of parts that weren't whitelisted
    --(e.g. baseplate, the dummy, etc):
	print(#boundBoxResult) 
	
	print(ovParams)
	-- OUTPUT: OverlapParams{MaxParts=false, CollisionGroup=Default, FilterDescendantsInstances={}}
	-- I literally set the OverlapParams and it still prints the default, WHY!?
end
3 Likes

Hello! I actually had the same “problem”, and it said I gave 4 arguments when 0 arguments were required.

You’ll want to do this instead:

local ovParams = OverlapParams.new() --this creates a blank OverlapParams thing
ovParams.FilterDescendantsInstances = {}
ovParams.CollisionGroup = "Default"
ovParams.FilterType = Enum.RaycastFilterType.Whitelist
ovParams.MaxParts = 1

Yeah, I was pretty confused until I figured out how to do it. They should probably have the documentation when releasing an update…

11 Likes