# setSoundMaxDistance (Shared)

> Sets the distance at which a 3D sound goes silent. The default is 20 m. On the server, the change is sent to every client.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Sound
- **URL**: https://wiki.mymp.gg/en/setSoundMaxDistance

## Syntax

```lua
bool setSoundMaxDistance(sound sound, float distance)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `sound` | `sound` | The `sound` element. On the client a `dui` element also works, for the browser's sound. |
| `distance` | `float` | The distance in metres. |

## Returns

`true` if the sound was found, `false` otherwise.

On the client, a 3D sound streams out when the camera is more than 40 m beyond this distance.

## Example

```lua
local siren = playSound3D("sounds/siren.ogg", 1544.0, -1675.5, 13.6, true)
setSoundMaxDistance(siren, 120)
```

## See also

- [getSoundMaxDistance (Shared)](https://wiki.mymp.gg/en/getSoundMaxDistance.md): Returns the distance at which a 3D sound goes silent.
- [setSoundMinDistance (Shared)](https://wiki.mymp.gg/en/setSoundMinDistance.md): Sets how far a 3D sound plays at full volume. The default is 5 m. On the server, the change is sent to every client.
- [playSound3D (Client)](https://wiki.mymp.gg/en/playSound3D-client.md): Plays a sound at a position in the world, on this client only. Its volume falls with distance between setSoundMinDistance (5 m) and setSoundMaxDistance (20 m). Fires onClientSoundStarted with play.
