# playSound (Server)

> Creates a sound with no position in the world that every client plays together. Changes made to it on the server reach everyone.

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

## Syntax

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

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `path` | `string` | Path of a file the resource sends to clients (a `<file>` in `meta.xml`). `@other/file.mp3` points to another resource. |
| `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 file could not be used (the reason is logged as a warning).

Players who join later hear the sound from where it is now. A sound that does not loop is destroyed by the server when it ends.

## Example

```lua
addEventHandler("onResourceStart", resourceRoot, function()
    playSound("sounds/event_start.mp3")
end)
```

### Coming from MTA

In MTA, `playSound` exists on the client only.

### Note

The file must be a client file of the resource, otherwise the function returns `false`.

## See also

- [playSound3D (Server)](https://wiki.mymp.gg/en/playSound3D-server.md): Creates a sound at a position in the world that every client plays together. Changes made to it on the server reach everyone.
- [stopSound (Server)](https://wiki.mymp.gg/en/stopSound-server.md): Stops a sound the server created and destroys the element on every client.
- [playSound (Client)](https://wiki.mymp.gg/en/playSound-client.md): Plays a sound with no position in the world, on this client only. Fires onClientSoundStarted with the reason play.
- [setSoundPaused (Shared)](https://wiki.mymp.gg/en/setSoundPaused.md): Pauses or resumes a sound. On the server, the change is sent to every client.
