How to know if a raycast is hitting a part without CastParams.FilterDescendantsInstances?

I want to place a part by clicking on the screen with a raycast, and I have the entire script for it already.

However, I want the preview (the half transparent duplicate of the part that moves with the mouse) to pass through already existing placed parts.

But if my part that I want to place is in the same spot as an already placed part, it should not allow it, and pop up a message on the screen saying “there’s something already there”.

For my part preview to pass through already existing parts and not stack (part placed on another part), I did the CastParams.FilterDescendantsInstances

Now, I’m thinking of storing all the placed parts positions into a table, but what if I have tens of thousands of parts? and I’m placing several parts a second? There has to be a better method. Thanks!

1 Like

I just switch between these two tables when I need to.

local raycastSelectionBlackList = {CenterPartWithTheArrows}
local raycastAttachmentBlackListList = {}

local CastParams = RaycastParams.new()
CastParams.FilterDescendantsInstances = raycastSelectionBlackList
CastParams.FilterType = Enum.RaycastFilterType.Exclude
1 Like

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