In order to do that you’d need to implement the different functionalities yourself.
FilterDescendantsInstances is used to specify ancestors you want to exclude/restrict to. You could write a simple helper function which takes the FilterDescendantsInstances you want to check against, and the instance, to determine if it should be filtered.
You can do that by looping over the filter descendants instances and checking like this: filterInstance == instanceToCheck or filterInstance:IsAncestorOf(instanceToCheck). You could also use instanceToCheck:IsDescendantOf(filterInstance) for the second half. That will tell you if its part of the filter, meaning it’s either the exact instance in the filter, or it’s under it.
If your check passes you can either return true or false immediately from within your filter loop, depending on which mode you’re using, which simultaneously will exit your loop and give you the result to tell you if that instance should be included or not. And then, by default, at the end of your loop, you would return the condition where the instance wasn’t part of the filter, and therefore should/shouldn’t be included.
If you wanted to check collision groups, just use some of the methods of PhysicsService to check if the two collision groups (the part’s and the RaycastParams) collide. If you want to test for collisions, check against CanCollide.
Since you won’t get touch events for water, you don’t care about the water check.
By implementing each field of RaycastParams you want to be able to use, you can then determine if any arbitrary instance should be included in your filter or not.
Here’s a quick example of FilterDescendantsInstances in particular, using some verbose variable names to help make the intent clear:
local function isFiltered(filterDescendantsInstances: {Instance}, instanceToCheck: Instance): boolean
for _, filterInstance in ipairs(filterDescendantsInstances) do
if filterInstance == instanceToCheck or filterInstance:IsAncestorOf(instanceToCheck) then
-- The filter instance matched the instance to check, or it was an ancestor of the instance to check
return true
end
end
-- None of the filter instances matched
return false
end
-- If Include mode, it's just if the instance was filtered
local shouldActuallyInclude = isFiltered(castParams.FilterDescendantsInstances, instanceToCheck)
-- If Exclude mode, it just gets inverted
local shouldActuallyInclude = not isFiltered(castParams.FilterDescendantsInstances, instanceToCheck)