PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

FindPartOnRayWithIgnoreList

Returns the first BasePart intersecting with the given DataType/Ray that isn’t in, or a descendant of an object in, the given ignore list.

This function also returns the position of intersection, the surface normal of the intersecting BasePart at the point of intersection, and the BasePart's BasePart/Material.

This function is a variant of Workspace/FindPartOnRay with the addition of an ignore list. This allows the developer to ignore certain BaseParts or Models.

The terrainCellsAreCubes and ignoreWater parameters determine whether terrain cells should be treated as cubes or not, and whether water should be ignored or not.

Those looking to utilize a white list instead should use Workspace/FindPartOnRayWithWhitelist.

Notes

  • Theoretically, a ray extends infinitely in one direction. However, the max length of the direction vector on Roblox is 5000 studs
  • The length of the direction vector is important - parts further away than its length will not be tested
  • If the ray does not intersect a part, the return values will be nil and the point at the end of the ray, respectively
  • If a nil value is given in the ignore list, instances after this value will not be ignored
  • Parts that are in a PhysicsService/SetPartCollisionGroup|collision group that does not collide with the “Default” collision group are ignored implicitly

For more information on how raycasting works in Roblox, please see the articles on raycasting basics and how to make raycasting guns.

Parameters

Name Type Default Description

ray

Ray

The DataType/Ray.

An array of objects to be ignored.

false

True if terrain cells should be treated as cubes.

false

True if terrain water should be ignored.

Returns

Return Type Summary

The BasePart (or Terrain) hit, the DataType/Vector3 point of intersection, the DataType/Vector3 surface normal at the point of intersection and the Enum/Material of the BasePart or terrain cell hit.


Code Samples


Raycast IgnoreList

This code sample includes a relatively in-depth example of how Workspace/FindPartOnRayWithIgnoreList works. It creates a rotating turret that shoots constantly surrounded by a mixture of parts. Some of these parts will be added to the ignore list, whereas some will not.