Discourse doesn’t like “FindPartsInRegion3WithWhitelist” for some reason, otherwise that would be in the title
Hello again, developers. Hope you all made it back safely from RDC and are ready to get back to working on your projects. Today we released something that I’m sure some of you have been hoping for, Workspace.FindPartsInRegion3WithWhiteList.
Starting off with the specifics, I implemented it in a similar way that I implemented FindPartOnRayWithWhitelist last year, which means there’s no functional difference between it and its IgnoreList counterpart, except one checks if parts are in the list provided, and one checks if they’re not.
Anyway, this allows you to provide a whitelist to check if any of its contents are parts within a provided region. Previously in order to do this, you had to either make an inverted blacklist, or look for all the parts and search the resulting table for the parts you want. Each case is not really ideal performance-wise, and is more work than should be necessary.
Here’s an example of how it works:
In this picture you’ll see I have 2 models, Reds, consisting of red parts, and Blues, consisting of blue parts
We are going to use this script to print out what we find:
local blues = workspace.Blues
local list1 = {reds, blues}
local list2 = {reds}
local region = Region3.new(
Vector3.new(-100,-20, -100),
Vector3.new(100,20,100)
)
local parts = workspace:FindPartsInRegion3WithWhiteList(region, list1, 10000)
for i = 1, #parts do
print(parts[i].Name)
end
print("-------------------TEST------------------------")
local parts = workspace:FindPartsInRegion3WithWhiteList(region, list2, 10000)
for i = 1, #parts do
print(parts[i].Name)
end
print("-------------------TEST------------------------")
local parts = workspace:FindPartsInRegion3WithIgnoreList(region, list2, 10000)
for i = 1, #parts do
print(parts[i].Name)
end
When this script runs, it prints out everything in the first list, which is all the red and blue parts, but not the Baseplate. Secondly it prints out everything in the second list, which is only red parts. Thirdly it prints out everything but red parts, including the Baseplate, since we’re using FPIR3WIL.
And that’s pretty much it. Let me know if you run into any issues and thanks for reading!