Component
Base component class for the component service Extended from NexusObject (by NexusAvenger)
Properties
InstanceObject
Component.InstanceObject: InstanceThe instance this Component is attached to.
ClassName
This item is read only and cannot be modified. Read OnlyComponent.ClassName: stringThe 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: stringThe component's unique identifier. This is used by ComponentService to identify or find the component.
IsServerOnly
Component.IsServerOnly: boolWhether this component should only be used by the server.
Default: false
IsServerOnly
Component.IsServerOnly: boolWhether this component should only be used by the client.
Default: false
Dormant
Component.Dormant: boolWhether 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: tableA whitelist of parents that this component can initialize under.
FromStatic
This item is read only and cannot be modified. Read OnlyComponent.FromStatic: boolWhether this object was static
Initialized
This item is read only and cannot be modified. Read OnlyComponent.Initialized: boolWhether this object was Initialized
Functions
SetClassName
Component:SetClassName(ClassName: string) → ()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
Overiddable constructor.
local lamp = Component:Extend()
function lamp:__new(Brightness : Number)
Component.__new(self)
self.Light.Brightness = Brightness
end
Extend
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(FieldName: string) → ()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(FieldName: string) → ()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.