GetComponent
7/14/25Less than 1 minute
GameObject.GetComponent(TComponent type)
Returns the component of Type type if the game object has one attached, null if it doesn't.
Parameters:
| Name | Type | Description | 
|---|---|---|
| type | TComponent | The type of Component to retrieve. | 
Returns:
| type | Description | 
|---|---|
| TComponent | component of Type | 
Usage
---@type GameObject
local gameobject;
---@type TComponent
local type;
local val0 = gameobject.GetComponent(type)
