TryGetComponent
7/14/25Less than 1 minute
MLStation.TryGetComponent(TComponent type)
Gets the component of the specified type, if it exists.
Parameters:
| Name | Type | Description |
|---|---|---|
| type | TComponent | The type of the component to retrieve. |
Returns:
| type | Description |
|---|---|
| boolean | Returns true if the component is found, false otherwise. |
| TComponent | The output argument that will contain the component or nil. |
Usage
---@type MLStation
local mlstation;
---@type TComponent
local type;
local val0, val1 = mlstation.TryGetComponent(type)Example
exists, component = myComponent.TryGetComponent(Transform);
-- exists is a boolean
-- component is Component or nil
