API reference
Raycasting
Rays, their options and their results.
RaycastParams.new([properties]) -> RaycastParamsNew options. Pass a table to set properties at once.
Arguments
| Name | Type | Description |
|---|---|---|
propertiesoptional | { [string]: any } |
Returns
RaycastParams
Example
Luau
local params = RaycastParams.new()
params.FilterDescendantsInstances = { player.Character }
params.FilterType = Enum.RaycastFilterType.ExcludeObjects the filter applies to, with everything inside them.
Returns
{ Instance }
Enum.RaycastFilterType.Exclude (the default: skip those objects) or Include (hit only them). A name or a number works too.
Returns
EnumItem
Skip parts that do not collide.
Returns
boolean
Kept for compatibility. Rays never hit water here.
Returns
boolean
Kept for compatibility. It does not change what a ray hits.
Returns
string
RaycastParams:AddToFilter(instances)Adds objects to FilterDescendantsInstances.
Arguments
| Name | Type | Description |
|---|---|---|
instances | Instance | { Instance } |
Example
Luau
params:AddToFilter(workspace.Ignore)The part that was hit.
Returns
BasePart
Where it was hit.
Returns
Vector3
The surface direction at the hit (unit length).
Returns
Vector3
Studs from the origin.
Returns
number
The part's Enum.Material (Plastic when it cannot be read).
Returns
EnumItem
Ray.new(origin, direction) -> RayA ray.
Arguments
| Name | Type | Description |
|---|---|---|
origin | Vector3 | |
direction | Vector3 |
Returns
Ray
Where it starts.
Returns
Vector3
Where it points, with its length.
Returns
Vector3
Ray:ClosestPoint(point) -> Vector3The point on the ray nearest to point.
Arguments
| Name | Type | Description |
|---|---|---|
point | Vector3 |
Returns
Vector3
Ray:Distance(point) -> numberThe distance from point to the ray.
Arguments
| Name | Type | Description |
|---|---|---|
point | Vector3 |
Returns
number