Can ray ignore a CollectionService tag?

Hello i am working on a gun based on raycasting, but i got a problem which i couldn’t solve. i have some collectble coins around the map which have tag in collection service. the problem is that the ray doesn’t ignore coins so the players can basically hide behind them. is it a way to put the coins tag inside the ray ignore list? if not so tell me because i got another ideas which could be little annoying.

From my brief reading of the documentation, it is possible.

Assuming coins are not a necessity to have under a certain parent, you can have them all parented under one model, using FindPartOnRayWithIgnoreList()'s “ignoreDescendantsInstance” argument to reference the model which will then ignore all of the coins that are descendants of that particular model.

1 Like

so basicly i need just to reference the model into the ignore list

and i didn’t mean to replay on the word you said ‘‘goreDescendantsInstance’’

You would loop through all of the objects and add them to a table:

local CS = game:GetService("CollectionService")
local Tag = CS:GetTagged("Tag")

local Ignore = {}

for i, Object in pairs(Tag) do
    if Object:IsA("BasePart") then
        table.insert(Ignore, Object)

--// Now this will make a ray that will ignore the tags

local Ray =, Vector2)
local Part = workspace:FindPartOnRayWithIgnoreList(Ray, Ignore)


You can also use FindPartOnRayWithWhiteList but that is only for parts that you want the ray to interact with.

1 Like