OnPlayerJoin
7/14/25Less than 1 minute
Room.OnPlayerJoin
"Read-Only"
This property is **Read-Only**
| Name | Type |
|---|---|
| OnPlayerJoin | EventHandler |
Event callback function requirement
Info
This property is an event. It means that you need to add a listener function to it. Here how that function needs to look like.
function(MLPlayer player);
Parameters
| Name | Type | Description |
|---|---|---|
| player | MLPlayer | The player who joined. |
Usage
--- callback function called when event triggers
--- @param mlplayer MLPlayer
local function CallBack(mlplayer)
-- code to handle event call back
end
-- Regsiter callback function
Room.OnPlayerJoin.Add(CallBack);Description
Event handler that gets invoked when a new player joins the room.
Example
Will pass the player who joined to as argument.
do -- script RoomManager
-- get reference to the script
local RoomManager = LUA.script;
local function OnPlayerJoin(player)
-- log the MLPlayer object passed in
Debug:Log(player);
end
-- start only called at beginning
function RoomManager.Start()
Room.OnPlayerJoin.Add(OnPlayerJoin);
end
end
