Intended Raycast Behaviour?

Hi, I’ve been trying to make a raycast fire until it hits a “valid” (occlusion) part, and I’m trying to wrap my head around how RaycastParams handles its FilterDescendantsInstances property.

local blacklist = {}
local params = RaycastParams.new()

params.FilterDescendantsInstances = blacklist
print( blacklist, params.FilterDescendantsInstances )

params.FilterDescendantsInstances = blacklist
print( blacklist, params.FilterDescendantsInstances )

RobloxStudioBeta_OXMOguaUEZ
The print here returns two different tables even though they’re set to the same table, when it’s much more convenient to set FilterDescendantsInstances once and be done with it.

Is this intended at all? Or do I just need to re-set the FilterDescendantsInstance table after I edit the blacklist table?
(And is it more efficient to just use FindPartOnRayWithIgnoreList?)

See, that it’s doing there is actually a pointer. A pointer is the position of the data in the memory, that doesn’t mean the tables aren’t identical, it just means that it allocated different memory positions for the tables, as there are two of them.

I mean, I already knew what pointers were.
My question was moreso why setting FilterDescendantsInstances creates a clone of the table instead of the tables themselves, when instead they could just use the table given to them.

it’s because you are applying the params to the same array
image
and then just changing its properties

1 Like