M MY Multiplayer: Wiki
Side
Kind

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

NameTypeDescription
playerNamestringThe 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)

See also