GuiObject
The base class of on-screen UI elements: a rectangle with a position, a size and a background.
- Inherits: Instance
- Subclasses: Frame, ImageLabel, TextLabel
- Creatable: No. It’s an abstract base class: create one of its subclasses, and check for it with
instanceoforisA('GuiObject'). - Replication: Replicated: clients get a copy, and changes the server makes reach them.
A GuiObject’s position and size each combine a fraction of its parent’s size (positionScale,
sizeScale) with pixels (position, size):
- left edge =
positionScale.x× parent width +position.x, then moved left byanchorPoint.x× its own width (and the same for the top edge); - width =
sizeScale.x× parent width +size.x(and the same for the height).
So sizeScale = (1, 0) with size = (0, 40) is full width and 40 pixels tall, and
positionScale = (0.5, 0.5) with anchorPoint = (0.5, 0.5) centers it. The parent is the
GuiObject it’s inside, or the screen for objects directly inside a ScreenGui.
Only GuiObjects are drawn: a GuiObject’s other children, such as a Folder, and everything inside them aren’t.
Properties
Section titled “Properties”position
Section titled “position”Type: Vector2 · Default: new Vector2(0, 0) · Access: read/write · Replicates: yes
Pixel offset.
positionScale
Section titled “positionScale”Type: Vector2 · Default: new Vector2(0, 0) · Access: read/write · Replicates: yes
Fraction of the parent (0–1).
Type: Vector2 · Default: new Vector2(100, 100) · Access: read/write · Replicates: yes
Pixels.
sizeScale
Section titled “sizeScale”Type: Vector2 · Default: new Vector2(0, 0) · Access: read/write · Replicates: yes
Fraction of the parent (0–1).
anchorPoint
Section titled “anchorPoint”Type: Vector2 · Default: new Vector2(0, 0) · Access: read/write · Replicates: yes
(0.5, 0.5) centers the object on its position.
backgroundColor
Section titled “backgroundColor”Type: Color3 · Default: Color3.fromHex('#ffffff') · Access: read/write · Replicates: yes
Fill color of the rectangle.
backgroundTransparency
Section titled “backgroundTransparency”Type: number · Default: 0 · Range: 0 to 1 (clamped) · Access: read/write · Replicates: yes
0 is opaque, 1 is invisible.
cornerRadius
Section titled “cornerRadius”Type: number · Default: 0 · Range: 0 or more (clamped) · Access: read/write · Replicates: yes
Pixels.
visible
Section titled “visible”Type: boolean · Default: true · Access: read/write · Replicates: yes
When false, the object and everything inside it are hidden.
zIndex
Section titled “zIndex”Type: number · Default: 1 · Access: read/write · Replicates: yes
Draw order among siblings: higher draws on top. Rounded to a whole number.
Inherited from Instance: name, archivable, id, className, parent, destroyed
Methods
Section titled “Methods”Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString
Events
Section titled “Events”Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged