Skip to main content

Room.RunForAnyPlayer(function function)

Assigns a function to run once for every player object when instantiated. This include the local player, players that were in the room before the local player, and for any player who will join later. The function will be triggered after the full instantiation of the player, so all the player components are present. The function will provide the related MLPlayer object.

Parameters:

NameTypeDescription
functionfunctionThe function to run for every player object.

Usage

---@type function
local function;


Room:RunForAnyPlayer(function)

Example

do
local script = LUA.script;

--@param player: MLPlayer
local function AddCollider(player)
player.AvatarTrackedObject.AddComponent(CapsuleCollider);
end

function script.Start()
Room.RunForAnyPlayer(AddCollider)
end
end