FindPartOnRayWithIgnoreList/Whitelist breaks if putting instances after a nil value in the table

When raycasting, if you put anything after a nil value in the table, for example:

workspace:FindPartOnRayWithIgnoreList(ray1, {nil, workspace.Baseplate}, true, true)

the ray will not collide with anything. The opposite happens with FindPartOnRayWithWhitelist, where it will collide with everything, even if it’s mentioned before the nil in the list.

For an example, check out this repro place in studio:

1 Like

This is probably because everything is considered a descendant of nil. I will look into this.
print(game.Workspace.Baseplate:IsDescendantOf(nil)) → true

2 Likes

This is expected behavior for arrays

for i, v in ipairs{1,2,nil,3} do print(v) end --> 1 2

Thank you SOOO MUCH I’ve been trying so hard to find out why this is happening!
WOW this is stupid someone please fix it .-.

local function fixIgnoreList(list)
	local list2 = {}
	for _, v in pairs(list) do
		list2[#list2 + 1] = v
	end
	return list2
end

workspace:FindPartOnRayWithIgnoreList(ray1, fixIgnoreList({nil, workspace.Baseplate}), true, true)

(You should probably find the root cause though)

1 Like

I have modified my code to not include nil values in my array of ignored objects, my point is that I shouldn’t have to. Roblox needs to fix something because this has had me stumped for days and I’m sure I’m not the only one.