---
title: "workspace:Raycast()"
description: "Casts a ray through the physics world and returns the first hit."
canonical: "https://docs.glorpia.com/scripting/functions/raycast"
markdown: "https://docs.glorpia.com/scripting/functions/raycast.md"
---
# workspace:Raycast()

Casts a ray through the physics world and returns the first hit.

**Category:** Scripting / Workspace method

## Syntax

```luau
workspace:Raycast(origin, direction)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `origin` | Vector3 | World-space ray start position. |
| `direction` | Vector3 | Direction and maximum distance. Its magnitude becomes the cast length. |

## Return value

| Name | Type | Description |
| --- | --- | --- |
| `Position` | Vector3 | World-space hit point. |
| `Normal` | Vector3 | Surface normal at the hit. |
| `Distance` | number | Distance from origin to the hit. |
| `Instance` | Instance? | Hit Glorpia instance when the collider maps to one. |

> **Note:** Returns `nil` when the direction is effectively zero or the ray does not hit anything.

## Example: Cast Downward

```luau
local origin = Vector3.new(0, 20, 0)
local direction = Vector3.new(0, -50, 0)
local hit = workspace:Raycast(origin, direction)

if hit then
    print("Hit", hit.Instance, "at", hit.Position)
    print("Distance", hit.Distance)
end
```
