# kickPlayer (Server)

> Disconnects a player from the server with a reason.

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

## Syntax

```lua
bool kickPlayer(player player [, string reason = kicked])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `player` | `player` | The player. |
| `reason` | `string` | The reason, which the launcher shows the player when the session ends. *(default: `kicked`)* |

## Returns

`true` if the player is being disconnected, `false` if the element is not a connected player.

## Example

```lua
addCommandHandler("afk", function(player)
    kickPlayer(player, "Away from keyboard")
end)
```

## See also

- [getPlayerFromName (Server)](https://wiki.mymp.gg/en/getPlayerFromName.md): Finds a player by exact name, case sensitive.
- [onPlayerQuit (Server)](https://wiki.mymp.gg/en/onPlayerQuit.md): Fired when a player leaves the server, before their element is destroyed.
- [getPlayerIP (Server)](https://wiki.mymp.gg/en/getPlayerIP.md): Returns the IP address the player is connected from, without the port.
