Hand-written by Joseph San Nicolas, Roblox Developer
RaycastParams
Constructors
| Name | Description |
| new() | Creates a new, blank RaycastParams object with default values for all properties. Properties can then be set on it and it can be reused across multiple raycasts. |
Code Snippet
local params = RaycastParams.new()
params.ExcludeInstances = {player.Character}
params.IgnoreWater = true
local origin = camera.CFrame.Position
local direction = camera.CFrame.LookVector * 100
local result = workspace:Raycast(origin, direction, params)
if result then
print("Hit:", result.Instance:GetFullName(), "at", result.Position)
end
Properties
| Name | Type | Description |
| ExcludeInstances | {Instance}? | An optional array of instances whose descendants will be excluded from the raycast query. |
| IncludeInstances | {Instance}? | An optional array of instances whose descendants will be the only ones included in the raycast query. |
| IgnoreWater | boolean | Determines whether Terrain water is considered during the raycast. |
| CollisionGroup | string | The name of the collision group to raycast against. Defaults to "Default" if not set. |
| RespectCanCollide | boolean | When true, a part's CanCollide property is also used (in addition to CanQuery) to determine whether it can be hit by the raycast. |
| BruteForceAllSlow | boolean | When true, ignores CanQuery/CanCollide filtering entirely and checks every part. Significantly hurts performance and is intended only for debugging. |
| FilterDescendantsInstances | Array | An array of instances whose descendants are used to filter raycast candidates, combined with FilterType. Superseded by ExcludeInstances/IncludeInstances but still supported. |
| FilterType | Enum.RaycastFilterType | Determines whether FilterDescendantsInstances is treated as an exclude list or an include list. Superseded by ExcludeInstances/IncludeInstances but still supported. |
Methods
| Name | Parameters | Returns | Description |
| AddToFilter(instances: Instance | {Instance}) | Instances: Instance or array of Instance | Void | Adds one or more instances to FilterDescendantsInstances without needing to reassign the whole array. |