Structural Class

From Legacy Roblox Wiki
Jump to navigationJump to search

A structural class (in the context of ROBLOX), or superclass is an object which is not actually used or possible to instantiate in-game, but is used as the basis from which certain other objects to inherit certain properties, events, and methods. All global properties are inherited from Instance, and then further structural classes exist.

No structural classes can be created in the game, sub-classes of them can be.

For example; the objects Part, TrussPart, and WedgePart all inherit their properties from the structural class BasePart; and all of the GUI objects inherit their properties and methods from GuiBase.

They are used to create objects, that while similar, play different roles. A TrussPart and a Part are quite similar in concept, and would require all of the same methods and properties, but are slightly divergent.

Instance
  BasePart
    Part
    WedgePart
    TrussPart
  GuiBase
    ScreenGui
    ImageLabel
    TextButton
Example

Using the IsA method, we can demonstrate the concept of superclasses.

wedge = Instance.new("WedgePart"))
print(wedge:IsA("BasePart"))
print(wedge:IsA("WedgePart"))
print(wedge:IsA("Part"))
print(wedge:IsA("Instance"))

would result in

true
true
false
true

WedgePart and Part share the same structural class BasePart, and are thus both considered to be BaseParts. WedgePart is also obviously a WedgePart, but it is important to note that WedgePart is not also a Part, just because of their shared ancestry. Additionally, all objects in ROBLOX inherit their properties from Instance, and thus all objects are considered to be an Instance.