Raycast ignore list help

I don’t have much experience with raycasting.

How would I create an ignore list for this raycast:

local Origin = Character.LeftHand.Position
local Direction = (EndPosition - Origin).Unit * 300
local Result = game.Workspace:Raycast(Origin, Direction)

Before asking, I’ve already checked other posts and haven’t had luck. Please comment if you are willing to help only.

1 Like
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist -- the ignore list type

raycastParams.FilterDescendantsInstances = {} -- put here things you want to be ignored

local Origin = Character.LeftHand.Position
local Direction = (EndPosition - Origin).Unit * 300

local raycastResult = workspace:Raycast(Origin,Direction, raycastParams)
if raycastResult then
  print(raycastResult.Instance) -- The part hit
  print(raycastResult.Position) -- The position where hit
  print(raycastResult.Material) --The material of the part it hit
  print(raycastResult.Normal) -- The surface normal 

Thanks. What would be the most efficient way of ignoring every single part in the game?

…Rather than looping through the map and inserting each part in the table

you can just do

raycastParams.FilterDescendantsInstances = {workspace}

Anyways, why do you wanna ignore every part in game? Doesnt it defeat the whole purpose of raycasting?

I’m trying to get a bullet not to be interfered by parts (and go through anything)
This is the right method?

yeah, or you can create a folder and put all the instances to ignore and in it and do:

raycastParams.FilterDescendantsInstances = {workspace.FolderNameHere}

I’ll give it a try, I’ll just say the whole of workspace