RayCastParams.Exclude Not Working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

To add excluded descendants to the ray cast params.

  1. What is the issue? Include screenshots / videos if possible!

Not working, excluded still being detected as a raycast instance.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

No solutions have worked.

Code:

local Params = RaycastParams.new()
			Params.FilterDescendantsInstances = script.Parent:GetDescendants()
			Params.FilterType = Enum.RaycastFilterType.Exclude
			local Raycast = workspace:Raycast(script.Parent.Position,Direction,Params)

The raycast params exclude part is the dependent’s of the parent. But the raycast still detects instance inside the parent.

Your .FilterDescendantsInstances should look like this:

Params.FilterDescendantsInstances = {script.Parent}
1 Like

Ok, I tried it, but the raycast still returns parts in the excluded filter

Could you show a picture of your explorer, and also the rest of the code?

wait a minute i just noticed something

I was doing script.Parent not script.Parent.Parent

so I was only getting the part in the filter

now its working

1 Like

You should mark your reply or my reply as the solution if it works now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.