Skip to main content

AudioSource.GetComponent(TComponent type)

Returns the component of Type type if the game object has one attached, nil if it doesn't.

Parameters:

NameTypeDescription
typeTComponentThe type of Component to retrieve.

Returns:

typeDescription
TComponentthe component of Type type

Usage

---@type AudioSource
local audiosource;

---@type TComponent
local type;


local val0 = audiosource.GetComponent(type)

Example

local transform = myComponent.GetComponent(Transform);