# setElementSyncer (Server)

> Chooses which player syncs a ped or vehicle.

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

## Syntax

```lua
bool setElementSyncer(element element [, player|nil player = nil, bool enable = true])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `element` | `element` | The ped or vehicle. |
| `player` | `player\|nil` | The player who syncs it from now on. With `nil`, nobody syncs it. *(default: `nil`)* |
| `enable` | `bool` | `false` stops the server from choosing anyone to sync it, and the given `player` is ignored. *(default: `true`)* |

## Returns

`true` if it applied, `false` if the element is not a ped or vehicle.

## Example

```lua
addCommandHandler("drive", function(player)
    local vehicle = createVehicle("infernus", 2495, -1687, 13.5)
    setElementSyncer(vehicle, player)
end)
```

### Note

The player only starts syncing if it already knows the element.

## See also

- [getElementSyncer (Server)](https://wiki.mymp.gg/en/getElementSyncer.md): Tells which player syncs an element, that is, which client simulates it and sends its state to the server.
- [isElementSyncer (Client)](https://wiki.mymp.gg/en/isElementSyncer.md): Tells whether this client syncs a ped or vehicle for the server.
- [onElementStartSync (Server)](https://wiki.mymp.gg/en/onElementStartSync.md): Fired when a player starts syncing a ped or vehicle.
