# playSound (Client)

> Plays a sound with no position in the world, on this client only. Fires `onClientSoundStarted` with the reason `play`.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Sound
- **URL**: https://wiki.mymp.gg/en/playSound-client
- **Counterpart**: Also exists on the server, with its own implementation: [playSound (Server)](https://wiki.mymp.gg/en/playSound-server.md)

## Syntax

```lua
sound|false playSound(string sound [, bool looped = false, bool throttled = true])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `sound` | `string` | A name registered with `engineAddSound`, the path of a file in the resource (`@other/file.mp3` for another resource) or the bytes of an audio file themselves. |
| `looped` | `bool` | Play the sound again from the start when it reaches the end. *(default: `false`)* |
| `throttled` | `bool` | Accepted for MTA compatibility and ignored. *(default: `true`)* |

## Returns

The created `sound` element, or `false` if the sound could not be opened.

When a sound that does not loop reaches its end, it fires `onClientSoundStopped` with `finished` and the element is destroyed.

## Example

```lua
local music = playSound("sounds/intro.ogg", true)
setSoundVolume(music, 0.5)
```

### Coming from MTA

Internet addresses (`http`, `ftp`) are not accepted. Another resource is named with `@resource/`, not `:resource/`.

## See also

- [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.
- [stopSound (Client)](https://wiki.mymp.gg/en/stopSound-client.md): Stops a sound this client created and destroys the element. Fires onClientSoundStopped with the reason destroyed.
- [playSound (Server)](https://wiki.mymp.gg/en/playSound-server.md): Creates a sound with no position in the world that every client plays together. Changes made to it on the server reach everyone.
- [engineAddSound (Client)](https://wiki.mymp.gg/en/engineAddSound.md): Registers an audio file under a name, which playSound and playSound3D then play by that name.
