Can't figure out how to filter a part from raycast with CanCollide on

I have these dominoes in my game, I want the player to not be able to walk over them, but be able to shoot (raycast) over them.

This is the hierarchy of a domino. Domino is CanCollide = false and CanQuery = false; InvisPart is CanCollide = true
image

This is my filter, Filter = {Player.Character, <AllDominoModels>}
image

I’ve tried setting CanQuery of InvisParts to false (CanCollide stays true) via script on runtime, but the raycast is still hitting the InvisPart of the dominoes. I am sure the raycast is hitting the InvisPart, I printed it.

So, why are my dominoes not getting filtered?

1 Like

Why not just run a for i,v in pairs() loop, get every Descendant of the Dominus, add every “InvisiblePart” into a table and just do it that way…?

1 Like

That was my initial approach, I had every InvisPart in the table, realised it gets descendants, then put every model in the table (taking out the InvisParts), still didn’t work. Tried setting CanCollide of the meshpart to true as well, since I thought maybe it’s not getting down to the InvisParts, since their parent has CanCollide off, but no luck, still doesn’t work.

1 Like

CanColide requires to have CanQuery enabled. Even if you forcefully disable CanQuery, it is still getting catched by raycasters

Are you sure you took correctly did the initial approach?

Local Item = — Any model:item, in this case your domin
Local Filter = {} — ur table
for i,v in pairs(Items:GetDescendents()) do
    if v:IsA(‘Part’) and v.Name == "InvisPart" then
        table.insert(Filter, v)
    end
end

Wrote this all on phone, should work though.

1 Like

Oh my… My obvious mistake hit me right in the face just now. Problem solved. The dominoes are a part of a map, which I’m cloning from ServerStorage. I was putting the original dominoes, not cloned ones, into the table :woozy_face: Sorry guys

1 Like

Do you add dominos after setting the filter Descendants. I had a problem a while ago where my ray casts were ignoring parts I had in a table because I was adding parts to the table but not updating the ray params

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