# triggerClientEvent (Server)

> Sends an event to the players' clients, which trigger it on `source`. The function returns before the clients receive it.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Server
- **Category**: Events
- **URL**: https://wiki.mymp.gg/en/triggerClientEvent

## Syntax

```lua
bool triggerClientEvent(string eventName, element source, any ... [, player|table|element sendTo = root])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `sendTo` | `player\|table\|element` | A player, a table of players, or an element whose descendant players get the event. Left out, it goes to every player. A player listed twice gets it once. *(default: `root`)* |
| `eventName` | `string` | The event's name on the clients. |
| `source` | `element` | The element the event happens on, on the clients. |
| `...` | `any` | Arguments passed to the handlers on the other side: `nil`, booleans, numbers, strings, elements, vectors and tables of them. |

## Returns

`true` if it was sent, `false` if the event is over 10 MB or a million values.

Elements created before the call reach the clients before the event. For more than 10 MB, use `triggerLatentClientEvent`.

## Example

```lua
addEventHandler("onPlayerSpawn", root, function()
    triggerClientEvent(source, "onShowWelcome", source, getPlayerName(source))
end)

triggerClientEvent("onRoundStart", resourceRoot, 300)
```

### Note

The client only accepts the event if it registered it with `addEvent(eventName, true)`. Otherwise it is dropped, and only the client's log says so.

## See also

- [addEvent (Shared)](https://wiki.mymp.gg/en/addEvent.md): Registers a new event under this name. Only then can handlers be added to it and can it be triggered.
- [triggerLatentClientEvent (Server)](https://wiki.mymp.gg/en/triggerLatentClientEvent.md): Sends an event to the players' clients bit by bit, in the background, at no more than bandwidth bytes a second per player. Meant for large data that must not hold up the rest of the traffic.
- [triggerServerEvent (Client)](https://wiki.mymp.gg/en/triggerServerEvent.md): Sends an event to the server, which triggers it on source there. The function returns before the server receives it.
