4 min read

Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.

RaycastParams

The RaycastParams data type stores parameters for WorldRoot:Raycast() operations. The ExcludeInstances and IncludeInstances properties store a set of objects and their descendants that will be excluded and included from the query. The RaycastParams.IgnoreWater property can be used to ignore Terrain water, and the RaycastParams.CollisionGroup property can specify a collision group for the raycasting operation.

This object is different from the similarly named RaycastResult which provides the results of a raycast.

Unlike most data types in Luau, you can change all of the members of RaycastParams without creating a new object, allowing you to reuse the same object repeatedly.

Constructors

NameType / ReturnsDescription
RaycastParams.newReturns a blank RaycastParams.

RaycastParams.new

Returns a blank RaycastParams object. Unlike other data type constructors, this constructor does not have any parameters, so you should set its properties appropriately.

Properties

NameType / ReturnsDescription
RaycastParams.ExcludeInstances{Instance}?An optional array of instances whose descendants will be excluded from the query.
RaycastParams.IncludeInstances{Instance}?An optional array of instances whose descendants will be included in the query.
RaycastParams.IgnoreWaterboolDetermines whether the water material is considered when raycasting against Terrain.
RaycastParams.CollisionGroupstringThe collision group used for the operation.
RaycastParams.RespectCanCollideboolDetermines whether the raycast operation considers a part's CanCollide property value over its CanQuery value.
RaycastParams.BruteForceAllSlowboolWhen enabled, the query will ignore all part collision properties and perform a brute-force check on every part.
RaycastParams.FilterDescendantsInstancesArrayAn array of objects whose descendants are used to filter raycasting candidates.
RaycastParams.FilterTypeRaycastFilterTypeDetermines whether the FilterDescendantsInstances array is used as an exclude or include list.

RaycastParams.ExcludeInstances

An optional array of instances whose descendants will be excluded from the query. This property can be used simultaneously with IncludeInstances to allow for mixed filtering, for example including a large folder but excluding specific child instances. If an instance matches both an exclude and include filter, exclusions take priority over inclusions.

FieldValue
type{Instance}?

RaycastParams.IncludeInstances

An optional array of instances whose descendants will be included in the query. This property can be used simultaneously with ExcludeInstances to allow for mixed filtering. If an instance matches both an exclude and include filter, exclusions take priority over inclusions.

Setting IncludeInstances to nil versus an empty array ({}) has opposite effects. IncludeInstances = nil is the most permissive filter (includes everything), whereas IncludeInstances = {} is the most restrictive filter (includes nothing).

FieldValue
type{Instance}?

RaycastParams.IgnoreWater

Determines whether the water material is considered when raycasting against Terrain.

FieldValue
typebool

RaycastParams.CollisionGroup

Specifies a collision group for the raycasting operation. Parts in collision groups that are set to not collide with this group are ignored. If this property is omitted, the raycast assumes the Default collision group.

FieldValue
typestring

RaycastParams.RespectCanCollide

This property, if true, makes the raycast operation use an intersected part's CanCollide value in favor of its CanQuery value when determining whether that part is included in the RaycastResult.

FieldValue
typebool

RaycastParams.BruteForceAllSlow

When enabled, the query will ignore all part collision properties and perform a brute-force check on every part. This will negatively impact performance and should not be used in live experiences.

FieldValue
typebool

RaycastParams.FilterDescendantsInstances

An array of objects whose descendants are used to filter raycasting candidates. Note that this property has been superseded by ExcludeInstances and IncludeInstances which should be used for new work.

FieldValue
typeArray

RaycastParams.FilterType

Determines whether the FilterDescendantsInstances array is used as an exclude or include list. Note that this property has been superseded by ExcludeInstances and IncludeInstances which should be used for new work.

FieldValue
typeRaycastFilterType

Methods

NameType / ReturnsDescription
RaycastParams:AddToFilter()Adds the instances provided to FilterDescendantsInstances.

RaycastParams:AddToFilter

Adds the instances provided to FilterDescendantsInstances. Note that this property has been superseded by ExcludeInstances and IncludeInstances which should be used for new work.

Parameters

NameTypeDefaultDescription
instancesInstance | ArrayAn instance or an array containing instances to add.

Returns

TypeDescription
()