Filter Descendant Instances not filtering all descendants?

So the filterDescendantInstances with raycasting leads me to believe it filters all descendants as in the name, I just want to clarify that it filters all descendants and not just the descendants of the current model if that makes sense. I have my character and values with models inside the values with parts in them and they are not being filtered out like my characters parts, if anyone knows how this works thankyou.

If something goes wrong, 95% of the time it is the user’s fault. You most likely are doing something wrong, care to share some code to further elaborate on your issue?

Yeah I’m not claiming it’s Roblox’s fault I get that it’s something I’m doing as said above, the code is in a module but the most I am doing is filtering out my Character with Blacklist enabled as shown here.

function General.Raycast (startingPosition, direction, ignoreList)
	local params = RaycastParams.new()
	params.FilterType = Enum.RaycastFilterType.Blacklist
	params.FilterDescendantsInstances = ignoreList
	params.IgnoreWater = true
	
	local result = workspace:Raycast(startingPosition, direction, params)
	return result
end

--My Ignore list passed would be {char}

Like I was saying there is a string value in my character with 2 weapon models and the weapon models parts are not being filtered out.

I see, and I wasn’t implying that you were doing something wrong; rather, it was more of an inference, haha! :sweat_smile:

I believe that using the table.unpack() function would be beneficial. Perhaps it doesn’t recognize it as a table, in which case… maybe this would…???


params.FilterDescendantsInstances = {table.unpack(ignoreList)};

I’m not sure, but it appears that you’re doing everything correctly.

Thankyou, I tried it with unpack and it’s still hitting the blade of my sword, The sword is 100% in my character inside a string value so I’m really not sure.

This is the hierarchy of my blade that keeps getting hit.

image

So you’re saying it worked to some sort of degree? Can you try hardcoding it first, and setting the actual character inside the table to see if that works? Maybe the sword isn’t a descendant of the player…? I’m kind of grasping right now, I apologize!

Uhh no it’s still hitting the same part after unpacking, yeah I’ll try that thanks.

Right, so I think I know the issue. The loop for finding all descendants is stopping because I believe that the StringValue instance prevents it from getting descendants. I think it strictly looks for the BasePart hierarchy only, so if not inside that, it will stop from looping, therefore skipping over those models. Try parenting those to a BasePart hierarchy.

I would actually thinking that could be the issue but that’s stupid since it’s still a descendant?

Let me try hardcoding the blade model itself into the table and see if that works and if it does should I just set up a extra function in the raycast saying “if the player has a weapon or fake weapon in their class string value then add it to the filter list”?

I think ROBLOX does this in a certain way to conserve resources, so it’s not iterating over absolutely everything. Since the value you’re using isn’t actually rendered in any plane of existence that the ray can interact with, rather just serves as a value, it’s skipped over (since filter descendants I’d assume only looks for actual parts that are rendered, thus being apart of the BasePart hierarchy only). That is the only conclusive thing I can pull from this, I apologize if this isn’t correct, however.

1 Like

Well this is weird, I hardcoded the 2 weapon models into the table and it still hits them lol?

repeat task.wait(.05) result = Server.Functions.General.Raycast(kunai.PrimaryPart.Position, Vector3.new(0,0,-3), {char, kunai, char.Ninja.NinjaWeapon, char.Ninja.FakeNinjaWeapon}) until result

Please refer to my last reply, I think that’s ultimately why. Try parenting it strictly to the BasePart hierarchy only?

Yeah I saw that, that’s the issue my whole games class system is wired around things being inside of the class string value in the player, I think I’ll try putting in the raycast function something like “if weapon then filter all baseparts” like I’ll add all it’s baseparts into the ignoreList, thankyou.

I’d reconsider your methods and would try approaching this differently, you shouldn’t strive to make hacky methods, so that not only can you conserve memory, but rather can practice efficient methods. Other than that, good luck! :grinning_face_with_smiling_eyes: :+1:

Thankyou, yeah I think this is the case where it’s more on Roblox for not filtering all descendants, the method of having a class value in the player shouldn’t be a issue imo.