- Documentation
- Server events
- onPlayerJoin
Event
onPlayerJoin
A player joined the server. A good place for a greeting, login and the first spawn.
Handler
addEventHandler("onPlayerJoin", root, function() ... end)Source
source is the player who joined the server.
Example
addEventHandler("onPlayerJoin", root, function()
outputChatBox(getPlayerName(source) .. " joined the game.", root, 140, 196, 232)
spawnPlayer(source, 2495.3, -1687.0, 13.5)
end)
Notes
Good to know. The event arrives when the player is already an element on the server but is not in the world yet. To reject a connection before joining (e.g. a bad nickname), use onPlayerConnect and cancelEvent(true, reason).
See also
spawnPlayerSpawns a player at the given place: position, rotation, skin, interior and dimension.outputChatBoxWrites a message in chat. On the server to one player or everyone, on the client in the local player's chat.addEventHandlerAttaches a function to an event. This is how you react to a player joining, dying, a key press, every frame and your own events.