onPlayerConnect
ServerEventCancellable
Fired when a connection is about to be admitted, before the player exists. Cancelling the event refuses it.
addEventHandler("onPlayerConnect", root, function(string playerName) … end)
Handler parameters
| Name | Type | Description |
|---|---|---|
| playerName | string | The name the player will join under: the account's Name#Tag on a server with a server_key, otherwise the name they brought. |
Source
The root element (root). The player does not exist yet.
Example
local banned = { ["Griefer#0001"] = true }
addEventHandler("onPlayerConnect", root, function(playerName)
if banned[playerName] then
cancelEvent()
end
end)