Skip to main content

Component

Base component class for the component service Extended from NexusObject (by NexusAvenger)

Properties

InstanceObject

Component.InstanceObject: Instance

The instance this Component is attached to.

ClassName

This item is read only and cannot be modified. Read Only
Component.ClassName: string

The classname of this component. You should always set this to the name of the file so that Intellisense can find it using the RobloxLSP plugin.

#Can be set using SetClassName

ID

Component.ID: string

The component's unique identifier. This is used by ComponentService to identify or find the component.

IsServerOnly

Component.IsServerOnly: bool

Whether this component should only be used by the server.

Default: false

IsServerOnly

Component.IsServerOnly: bool

Whether this component should only be used by the client.

Default: false

Dormant

Component.Dormant: bool

Whether this component should be initialized immediately. This is useful if you have a component on an object that is not used. Example: A gun in replicatedstorage.

Default: true

DormancyWhiteList

Component.DormancyWhiteList: table

A whitelist of parents that this component can initialize under.

Default: {workspace, game.Players, game.ReplicatedFirst}

FromStatic

This item is read only and cannot be modified. Read Only
Component.FromStatic: bool

Whether this object was static

Initialized

This item is read only and cannot be modified. Read Only
Component.Initialized: bool

Whether this object was Initialized

Functions

SetClassName

Component:SetClassName(ClassNamestring) → ()

Sets the classname of this component. You should always set this to the name of the file so that Intellisense can find it using the RobloxLSP plugin.

    local TestComponent = Component:Extend()
    TestComponent:SetClassName("TestComponent")

    print(TestComponent:IsA("TestComponent")) -- true

__new

Component:__new(
...any--

The parameters you've specified

) → Component

Overiddable constructor.

local lamp = Component:Extend()
function lamp:__new(Brightness : Number)
    Component.__new(self)
    self.Light.Brightness = Brightness
end

Extend

Component:Extend() → Component

Allows you to extend the class into a new one.

local lamp = Component:Extend()
function lamp:Shine()
    lamp.LampObject.Enabled = true;
    print("oop doop")
end

local lamp2 = lamp:Extend()

function lamp2:Shine()
    lamp.Shine(self)
    print("Lamp is shining!")
end

local l1 = lamp.new()
local l2 = lamp2.new()

l1:Shine()
--output: 
--oop doop

l2:Shine()
--output:
--oop doop
--Lamp is shining!

For more info on NexusObject and how to use it: https://github.com/TheNexusAvenger/Nexus-Instance

HideField

Component:HideField(FieldNamestring) → ()

Hides a field from the Component creator. When creating a new component from the creator plugin, the settings script will not include this field

ShowField

Component:ShowField(FieldNamestring) → ()

Unhides a field from the Component creator. When creating a new component from the creator plugin, the settings script will return to including this field

NOTE: You do not need to call this on all your fields, fields that are not hidden will automatically be shown

InstanceDestroyed

Component:InstanceDestroyed() → ()

Gets called when the Component gets :Destroy() 'ed. You should remove all connections that this component has while getting destroyed so it can be collected by Garbage collection. NOTE: This might be done automatically however I'm not sure.

Show raw api
{
    "functions": [
        {
            "name": "SetClassName",
            "desc": "Sets the classname of this component.\nYou should always set this to the name of the file so that Intellisense can find it using the RobloxLSP plugin.\n\n```lua\n    local TestComponent = Component:Extend()\n    TestComponent:SetClassName(\"TestComponent\")\n\n    print(TestComponent:IsA(\"TestComponent\")) -- true\n```",
            "params": [
                {
                    "name": "ClassName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 46,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "__new",
            "desc": "Overiddable constructor.\n```lua\nlocal lamp = Component:Extend()\nfunction lamp:__new(Brightness : Number)\n    Component.__new(self)\n    self.Light.Brightness = Brightness\nend\n```",
            "params": [
                {
                    "name": "...",
                    "desc": "The parameters you've specified",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Component"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 69,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "Extend",
            "desc": "Allows you to extend the class into a new one.\n```lua\nlocal lamp = Component:Extend()\nfunction lamp:Shine()\n    lamp.LampObject.Enabled = true;\n    print(\"oop doop\")\nend\n\nlocal lamp2 = lamp:Extend()\n\nfunction lamp2:Shine()\n    lamp.Shine(self)\n    print(\"Lamp is shining!\")\nend\n\nlocal l1 = lamp.new()\nlocal l2 = lamp2.new()\n\nl1:Shine()\n--output: \n--oop doop\n\nl2:Shine()\n--output:\n--oop doop\n--Lamp is shining!\n\n```\nFor more info on NexusObject and how to use it: https://github.com/TheNexusAvenger/Nexus-Instance",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Component"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 104,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "HideField",
            "desc": "Hides a field from the Component creator.\nWhen creating a new component from the creator plugin, the settings script will not include this field",
            "params": [
                {
                    "name": "FieldName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 217,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "ShowField",
            "desc": "Unhides a field from the Component creator.\nWhen creating a new component from the creator plugin, the settings script will return to including this field\n\nNOTE: You do not need to call this on all your fields, fields that are not hidden will automatically be shown",
            "params": [
                {
                    "name": "FieldName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 228,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "InstanceDestroyed",
            "desc": "Gets called when the Component gets :Destroy() 'ed.\nYou should remove all connections that this component has while getting destroyed so it can be collected by Garbage collection.\nNOTE: This might be done automatically however I'm not sure.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 273,
                "path": "Component/Component.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "InstanceObject",
            "desc": "The instance this Component is attached to.",
            "lua_type": "Instance",
            "source": {
                "line": 19,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "ClassName",
            "desc": "The classname of this component.\nYou should always set this to the name of the file so that Intellisense can find it using the RobloxLSP plugin.\n\n#Can be set using [SetClassName](/api/Component#SetClassName)",
            "lua_type": "string",
            "readonly": true,
            "source": {
                "line": 30,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "ID",
            "desc": "The component's unique identifier.\nThis is used by ComponentService to identify or find the component.",
            "lua_type": "string",
            "source": {
                "line": 54,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "__hiddenFields",
            "desc": "All the fields hidden by the HideField function",
            "lua_type": "table",
            "private": true,
            "source": {
                "line": 115,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "IsServerOnly",
            "desc": "Whether this component should only be used by the server.\n\nDefault: [false]()",
            "lua_type": "bool",
            "source": {
                "line": 125,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "IsServerOnly",
            "desc": "Whether this component should only be used by the client.\n\nDefault: [false]()",
            "lua_type": "bool",
            "source": {
                "line": 134,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "Dormant",
            "desc": "Whether this component should be initialized immediately.\nThis is useful if you have a component on an object that is not used.\nExample: A gun in replicatedstorage.\n\nDefault: [true]()",
            "lua_type": "bool",
            "source": {
                "line": 145,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "DormancyWhiteList",
            "desc": "A whitelist of parents that this component can initialize under.\n\n\nDefault: [{workspace, game.Players, game.ReplicatedFirst}]()",
            "lua_type": "table",
            "source": {
                "line": 155,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "FromStatic",
            "desc": "Whether this object was static",
            "lua_type": "bool",
            "readonly": true,
            "source": {
                "line": 164,
                "path": "Component/Component.lua"
            }
        },
        {
            "name": "Initialized",
            "desc": "Whether this object was Initialized",
            "lua_type": "bool",
            "readonly": true,
            "source": {
                "line": 173,
                "path": "Component/Component.lua"
            }
        }
    ],
    "types": [],
    "name": "Component",
    "desc": "Base component class for the component service\nExtended from NexusObject (by NexusAvenger)",
    "source": {
        "line": 11,
        "path": "Component/Component.lua"
    }
}