RayCasting Ignore List Help

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!
    I’m trying to create a pistol using raycasting

  2. What is the issue? Include screenshots / videos if possible!
    I cannot input a table of ignored objects into the raycast

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

I’ve tried making a separate table and adding all the ignored parts, but I think I’ve made it more confusing.

local ignoredlist = {}

local part = {}
wait()
for i, v in pairs(character:GetChildren()) do
	if v:IsA("Part") then
		table.insert(part,1,v)
	end
end

table.insert(ignoredlist,1, part) 
table.insert(ignoredlist,3, pistol:GetChildren())

print(ignoredlist)
pistol.Activated:Connect(function()
	if not debounce then
		debounce = true
		
		local aRay = Ray.new(barrel.Position, (Vector3.new(0,0,0) + (barrel.CFrame.LookVector * 100000)))
		local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(aRay, ignoredlist, false, false)

It is my first time using raycast and I don’t understand how to put ignored items using tables. I am trying to make the barrel of the pistol and the character ignored from the raycast.

1 Like

You need to pass a RaycastParams | Roblox Creator Documentation object to filter out objects from the raycast.

Here is an example:

local raycastParams = RaycastParams.new()
		raycastParams.FilterDescendantsInstances = {Model}
		raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
		raycastParams.IgnoreWater = true

You would pass this in to your raycast as the third argument, after the two Vector3 values.

1 Like

you can use the findpartonraywithignorelist. However, it seems that you getting all descendants of a pistol to ignore. To fix this, you can either ignore the character or tool it selfs. Ray cast ignore the ancestors descendants too!