Whitelist Returning Anything if First Index is nil

If you give workspace:FindPartOnRayWithWhitelist() an array with the first index being nil, the function will return anything that the ray hits, including artifacts outside of the whitelist.

The bug happens 100% of the time in studio and on the client.

Here is a quick video demo of the bug happening:

I do not know when the bug started happening.

Notes:

  1. Upon further investigation, if a nil index is present anywhere in the whitelist, the bug will occur.
  2. Here is the repro place I created: WhitelistReturningAnything.rbxl (16.5 KB)
  3. (EDIT) The bug appears to happen on the client as well. Here’s a published place: ### ######### Bug Place - Roblox
1 Like

The reason this happens is because everything is considered a descendant of nil.

print(game.Workspace.Baseplate:IsDescendantOf(nil))
> true
6 Likes

The correct way of testing this is not instance:IsDescendantOf(game).

That’s understandable, but how expensive is it to ignore indices with nil values when checking IsDescendantOf?

2 Likes

I’m not sure if everything being considered a descendant of nil is good behaviour, I was just noting that how this currently works is consistent with other APIs. The current behaviour of this function is definitely very unintuitive and should be changed.

6 Likes