# onClientWorldSound (Client)

> Fired when the game is about to play a world sound. Cancelling the event keeps the sound from playing.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Event
- **Side**: Client
- **Category**: Sound
- **Cancellable**: `cancelEvent`
- **URL**: https://wiki.mymp.gg/en/onClientWorldSound

## Syntax

```lua
addEventHandler("onClientWorldSound", root, function(int group, int index, float x, y, z) ... end)
```

## Handler parameters

| Name | Type | Description |
| --- | --- | --- |
| `group` | `int` | The sound's group (SA's bank slot). |
| `index` | `int` | The sound's index inside the group. |
| `x, y, z` | `float` | Where the sound plays. |

## Source

The element of the entity making the sound (a ped, vehicle or object), or the root element (`root`) if there is none.

## Example

```lua
addEventHandler("onClientWorldSound", localPlayer, function(group, index)
    if group == 5 then
        cancelEvent()
    end
end)
```

### Note

Collision sounds worked out by the parallel physics and sounds with an index above 399 play without firing the event. A sound turned off with `setWorldSoundEnabled` does not fire it either.

## See also

- [setWorldSoundEnabled (Client)](https://wiki.mymp.gg/en/setWorldSoundEnabled.md): Turns the game world's sounds (footsteps, gunfire, collisions and more) on or off by group or one by one.
- [showSound (Client)](https://wiki.mymp.gg/en/showSound.md): Writes the group and index of every world sound that plays to the debug console. Works only in development mode.
