Widget
UI element type returned by the UI service: labels, buttons, text boxes, layout containers and windows.
local window = UI:CreateWindow(260, 180)
local row = window:AddRow()
local buy = row:AddButton("Buy sword")
buy.Pressed:Connect(function()
game:GetService("Remote"):FireServer("Buy", "Sword")
end)Properties
Text
widget.Text: stringText content of a label, button or text box.
TextColor
widget.TextColor: Color3TextSize
widget.TextSize: numberTextAlignment
widget.TextAlignment: stringHorizontal alignment: Left, Center or Right.
Visible
widget.Visible: booleanWhether the widget is rendered.
X
widget.X: numberHorizontal offset in pixels. Y, Width and Height are also available.
Grow
widget.Grow: booleanExpands the widget to fill the available width of its container. Tall does the same vertically.
BackgroundColor
widget.BackgroundColor: Color3Background color of a window or panel. BackgroundTransparency, BorderColor and BorderSize are also available.
Selected
widget.Selected: booleanRenders a button in its selected state. Starred adds a star marker.
Methods
AddLabel
widget:AddLabel(text: string, size: number?, bold: boolean?): WidgetAdds a text label. size ranges from 8 to 40.
AddButton
widget:AddButton(text: string, style: string?): WidgetAdds a button. style is "flat" or "list".
AddTextBox
widget:AddTextBox(placeholder: string?): WidgetAdds a single-line text input.
AddSwatch
widget:AddSwatch(color: Color3, tip: string?): WidgetAdds a color swatch button. tip sets its tooltip.
AddPicture
widget:AddPicture(options: table): WidgetAdds a rendered thumbnail of a part defined by Shape, Material and Color.
AddRow
widget:AddRow(): WidgetAdds a horizontal layout container.
AddColumn
widget:AddColumn(width: number?): WidgetAdds a vertical layout container.
AddList
widget:AddList(width: number?): WidgetAdds a vertically scrolling list.
AddGrid
widget:AddGrid(columns: number?, tileSize: number?): WidgetAdds a scrolling grid of columns columns with tileSize tiles.
FindFirstChild
widget:FindFirstChild(name: string): Widget?Returns the child widget with the given name, or nil.
Clear
widget:Clear()Destroys every child widget.
Destroy
widget:Destroy()Destroys the widget and its children.
Events
Pressed
widget.Pressed()Fires when a button is clicked.
RightPressed
widget.RightPressed()Fires when a button is right-clicked.
Changed
widget.Changed(text: string)Fires when a text box's contents change.