Skip to main content

ComponentService

Handles all the components and setup

Properties

CheckDescendants

Configuration
ComponentService.CheckDescendants: bool

Whether the service should check descendants for all the folders in ComponentFolders. When false, the service will check for children instead.

default = true

ComponentFolders

Configuration
ComponentService.ComponentFolders: table

A table with all the

default = true

ComponentsByType

This item is read only and cannot be modified. Read Only
ComponentService.ComponentsByType: table

A dictionary of all components existant in the world indexed by their type

ComponentsByID

This item is read only and cannot be modified. Read Only
ComponentService.ComponentsByID: table

A dictionary of all components existant in the world indexed by their ID

ComponentsByInstance

This item is read only and cannot be modified. Read Only
ComponentService.ComponentsByInstance: table

A dictionary of all components attached to an instance

ComponentsByInstanceType

This item is read only and cannot be modified. Read Only
ComponentService.ComponentsByInstanceType: table

A dictionary of all components attached to an instance, sorted by their type

Functions

InitializeGame

ComponentService.InitializeGame(
ComponentFolderstable?--

A list of components that the service should load. These can later be used to create components using InitializeGame or InitializeGame

) → ()

Initializes the game. This should be called on both client and server, if you use the server for Components. You can optionally provide your own Component Folders, if you're not using the configuration.

AddComponent

ComponentService.AddComponent(
ComponentNamestring,
InstanceObjectInstance,
...any--

Any parameters that you want to pass into the Components constructor (__new)

) → Component

Adds a new component to the Object.

GetComponent

ComponentService.GetComponent(
ComponentNamestring,
InstanceObjectInstance
) → Component

Gets a component attached to the Object.

GetComponentsOfType

ComponentService.GetComponentsOfType(
ComponentNamestring,
InstanceObjectInstance
) → Component

Gets all components attached to the Object of type ComponentName. ComponentName should be the ClassName of the component

GetComponents

ComponentService.GetComponents(InstanceObjectInstance) → {Component}

Gets all components attached to the Object.

FindComponentsOfType

ComponentService.FindComponentsOfType(ComponentNamestring) → {Component}

Gets all components of type ComponentName. ComponentName should be the ClassName of the component

Show raw api
{
    "functions": [
        {
            "name": "InitializeGame",
            "desc": "Initializes the game. This should be called on both client and server, if you use the server for Components.\nYou can optionally provide your own Component Folders, if you're not using the configuration.",
            "params": [
                {
                    "name": "ComponentFolders",
                    "desc": "A list of components that the service should load. These can later be used to create components using [InitializeGame](/api/ComponentService#AddComponent) or [InitializeGame](/api/ComponentService#GetComponent)",
                    "lua_type": "table?"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 97,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "AddComponent",
            "desc": "Adds a new component to the Object.",
            "params": [
                {
                    "name": "ComponentName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "InstanceObject",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "...",
                    "desc": "Any parameters that you want to pass into the Components constructor [(__new)](/api/Component#__new)",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Component"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 128,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "GetComponent",
            "desc": "Gets a component attached to the Object.",
            "params": [
                {
                    "name": "ComponentName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "InstanceObject",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Component"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 136,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "GetComponentsOfType",
            "desc": "Gets all components attached to the Object of type <string>ComponentName.\nComponentName should be the [ClassName](/api/Component#ClassName) of the component",
            "params": [
                {
                    "name": "ComponentName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "InstanceObject",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Component"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 150,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "GetComponents",
            "desc": "Gets all components attached to the Object.",
            "params": [
                {
                    "name": "InstanceObject",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{Component}"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 163,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "FindComponentsOfType",
            "desc": "Gets all components of type ComponentName.\nComponentName should be the [ClassName](/api/Component#ClassName) of the component",
            "params": [
                {
                    "name": "ComponentName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{Component}"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 172,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "_instantiate",
            "desc": "Instantiates a new Component.",
            "params": [
                {
                    "name": "ComponentName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "InstanceObject",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "Settings",
                    "desc": "",
                    "lua_type": "table"
                },
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Component"
                }
            ],
            "function_type": "static",
            "private": true,
            "source": {
                "line": 194,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "_instantiateStatic",
            "desc": "Instantiates a new Component without constructing it.\nUsed for static Components attached to existing objects.",
            "params": [
                {
                    "name": "ComponentName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "InstanceObject",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "ComponentSettings",
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Component"
                }
            ],
            "function_type": "static",
            "private": true,
            "source": {
                "line": 217,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "_gameObjectAdded",
            "desc": "Fired when an instance is added to the game.\nThis is used to create components on newly created objects.",
            "params": [
                {
                    "name": "Object",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [],
            "function_type": "static",
            "private": true,
            "source": {
                "line": 294,
                "path": "Component/ComponentService.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "CheckDescendants",
            "desc": "Whether the service should check descendants for all the folders in ComponentFolders.\nWhen false, the service will check for children instead.\n\ndefault = [true]()",
            "lua_type": "bool",
            "tags": [
                "Configuration"
            ],
            "source": {
                "line": 40,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "ComponentFolders",
            "desc": "A table with all the \n\ndefault = [true]()",
            "lua_type": "table",
            "tags": [
                "Configuration"
            ],
            "source": {
                "line": 49,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "ComponentsByType",
            "desc": "A dictionary of all components existant in the world indexed by their type",
            "lua_type": "table",
            "readonly": true,
            "source": {
                "line": 57,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "ComponentsByID",
            "desc": "A dictionary of all components existant in the world indexed by their ID",
            "lua_type": "table",
            "readonly": true,
            "source": {
                "line": 65,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "ComponentsByInstance",
            "desc": "A dictionary of all components attached to an instance",
            "lua_type": "table",
            "readonly": true,
            "source": {
                "line": 73,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "ComponentsByInstanceType",
            "desc": "A dictionary of all components attached to an instance, sorted by their type",
            "lua_type": "table",
            "readonly": true,
            "source": {
                "line": 81,
                "path": "Component/ComponentService.lua"
            }
        },
        {
            "name": "_componentTypes",
            "desc": "Holds all the components, indexed by their names.\nThis is automatically filled when [InitializeGame](/api/ComponentService#InitializeGame) is called.",
            "lua_type": "table",
            "private": true,
            "source": {
                "line": 90,
                "path": "Component/ComponentService.lua"
            }
        }
    ],
    "types": [],
    "name": "ComponentService",
    "desc": "Handles all the components and setup",
    "source": {
        "line": 6,
        "path": "Component/ComponentService.lua"
    }
}