# onPlayerSpawn (Server)

> Fired after `spawnPlayer` spawns a player.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Event
- **Side**: Server
- **Category**: Players and accounts
- **URL**: https://wiki.mymp.gg/en/onPlayerSpawn

## Syntax

```lua
addEventHandler("onPlayerSpawn", root, function() ... end)
```

## Source

The player that spawned.

## Example

```lua
addEventHandler("onPlayerSpawn", root, function()
    setElementHealth(source, 100)
    setElementData(source, "spawnedAt", getTickCount())
end)
```

## See also

- [spawnPlayer (Server)](https://wiki.mymp.gg/en/spawnPlayer.md): Places the player in the world, with health at 100, no armour, in interior 0 and with no weapons.
- [isPlayerSpawned (Server)](https://wiki.mymp.gg/en/isPlayerSpawned.md): Tells whether the player has been placed in the world by spawnPlayer.
- [onPlayerJoin (Server)](https://wiki.mymp.gg/en/onPlayerJoin.md): Fired when a player has finished joining and has received the server's initial state.
