Skip to content

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 instanceof or isA('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 by anchorPoint.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.

Type: Vector2 · Default: new Vector2(0, 0) · Access: read/write · Replicates: yes

Pixel offset.

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.

Type: Vector2 · Default: new Vector2(0, 0) · Access: read/write · Replicates: yes

Fraction of the parent (0–1).

Type: Vector2 · Default: new Vector2(0, 0) · Access: read/write · Replicates: yes

(0.5, 0.5) centers the object on its position.

Type: Color3 · Default: Color3.fromHex('#ffffff') · Access: read/write · Replicates: yes

Fill color of the rectangle.

Type: number · Default: 0 · Range: 0 to 1 (clamped) · Access: read/write · Replicates: yes

0 is opaque, 1 is invisible.

Type: number · Default: 0 · Range: 0 or more (clamped) · Access: read/write · Replicates: yes

Pixels.

Type: boolean · Default: true · Access: read/write · Replicates: yes

When false, the object and everything inside it are hidden.

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

Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString

Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged