# sm.util.clamp

Restricts a value to a given range.

**Kind:** Function

**Environments:** Game, Terrain

## Game

``` { .lua .api-signature }
sm.util.clamp( value, min, max )
```

[Open the full Game reference](../Game-Script-Environment/Static-Functions/sm.util.md#clamp)

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `value` | number | The value. |
| `min` | number | The lower limit. |
| `max` | number | The upper limit. |

**Returns:**

| Type | Description |
| --- | --- |
| number | The clamped value. |

## Terrain

``` { .lua .api-signature }
sm.util.clamp( value, min, max )
```

[Open the full Terrain reference](../Terrain-Script-Environment/Static-Functions/sm.util.md#clamp)

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `value` | number | The value. |
| `min` | number | The lower limit. |
| `max` | number | The upper limit. |

**Returns:**

| Type | Description |
| --- | --- |
| number | The clamped value. |
