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
| Name | Type / Returns | Description |
|---|---|---|
| RaycastParams.new | Returns 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
| Name | Type / Returns | Description |
|---|---|---|
| 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.IgnoreWater | bool | Determines whether the water material is considered when raycasting against Terrain. |
| RaycastParams.CollisionGroup | string | The collision group used for the operation. |
| RaycastParams.RespectCanCollide | bool | Determines whether the raycast operation considers a part's CanCollide property value over its CanQuery value. |
| RaycastParams.BruteForceAllSlow | bool | When enabled, the query will ignore all part collision properties and perform a brute-force check on every part. |
| RaycastParams.FilterDescendantsInstances | Array | An array of objects whose descendants are used to filter raycasting candidates. |
| RaycastParams.FilterType | RaycastFilterType | Determines 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.
| Field | Value |
|---|---|
| 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).
| Field | Value |
|---|---|
| type | {Instance}? |
RaycastParams.IgnoreWater
Determines whether the water material is considered when raycasting against Terrain.
| Field | Value |
|---|---|
| type | bool |
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.
| Field | Value |
|---|---|
| type | string |
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.
| Field | Value |
|---|---|
| type | bool |
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.
| Field | Value |
|---|---|
| type | bool |
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.
| Field | Value |
|---|---|
| type | Array |
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.
| Field | Value |
|---|---|
| type | RaycastFilterType |
Methods
| Name | Type / Returns | Description |
|---|---|---|
| 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
| Name | Type | Default | Description |
|---|---|---|---|
| instances | Instance | Array | An instance or an array containing instances to add. |
Returns
| Type | Description |
|---|---|
| () |