---
title: "Raycast hit table"
---

> Documentation Index
> Fetch the complete documentation index at: https://aesthetic-docs.pages.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Raycast hit table

Returned by `world:raycast`, `world:raycast_entity` and `player:raycast`. Check `type`
to see what was hit — `player:raycast` can return either kind.

## Every hit

| Field | Meaning |
|-------|---------|
| `type` | `"block"` or `"entity"` |
| `pos` | Exact hit point as [vec3](/vec3) |
| `distance` | Distance from ray start to hit |

## Block hits (`type == "block"`)

| Field | Meaning |
|-------|---------|
| `block_pos` | Hit block position as [vec3](/vec3) |
| `side` | Hit face: `"up"`, `"down"`, `"north"`, `"south"`, `"east"`, `"west"` |
| `inside` | `true` if the ray started inside the block |
| `state` | [Block state handle](/block-state) of the hit block |

## Entity hits (`type == "entity"`)

| Field | Meaning |
|-------|---------|
| `entity` | [Entity handle](/entity) of the hit entity |

```lua
local hit = player:raycast(20)
if hit then
if hit.type == "entity" then
    print("looking at " .. hit.entity:name())
else
    print("looking at " .. hit.state:name() .. " (" .. hit.side .. ")")
end
end
```

Source: https://aesthetic-docs.pages.dev/raycast/index.md
