Datatype · Userdata

Control

userdata

Control proxy returned by every Category:add_* method. The proxy survives across UI redraws as long as the owning tab and category exist. After :destroy() (or implicit destruction via Tab:destroy / rbxcli_ui.clear) the proxy becomes inert: :get() returns nil, :set becomes a no-op, and the runtime emits a one-shot warning on first stale call. The value type returned by :get() and accepted by :set() depends on which add_* method produced the control. Kind-specific methods (enable, disable, toggle, set_index, get_index, update_options, set_key, get_key) raise a Luau error when called on the wrong control kind.

Fields

NameTypeDescription
destroy() -> ()

Marks the control as destroyed. The visual element is removed on the next UI refresh.

disable() -> ()

Toggle-only. Sets the boolean to false and queues the change callback. Raises a Luau error on any other kind.

enable() -> ()

Toggle-only. Sets the boolean to true and queues the change callback. Raises a Luau error on any other kind.

get() -> boolean | number | string | { number } | nil

Reads the current value. Returns boolean for Toggle, number for SliderFloat / SliderInt / Dropdown index / Keybind code, string for Input / Label, {r, g, b, a} table for Color, and nil for Button / Separator or any destroyed control.

get_index() -> number

Dropdown-only. Returns the current 0-based selected index. Raises a Luau error on any other kind.

get_key() -> number

Keybind-only. Returns the current key code. Raises a Luau error on any other kind.

set(value: boolean | number | string | { number }) -> ()

Writes the value. The argument type must match the control kind: boolean for Toggle, number for SliderFloat / SliderInt / Dropdown / Keybind, string for Input / Label, {r, g, b, a} table for Color. Missing components in a Color table preserve the previous component.

set_index(index: number) -> ()

Dropdown-only. Sets the 0-based selected index and queues the change callback. Raises a Luau error on any other kind.

set_key(key: number) -> ()

Keybind-only. Sets the key code and queues the change callback. Raises a Luau error on any other kind.

set_label(text: string) -> ()

Replaces the control's label. Valid on every kind.

set_visible(visible: boolean) -> ()

Shows or hides the control. Hidden controls skip rendering but remain alive and continue to hold their state. Valid on every kind.

toggle() -> boolean

Toggle-only. Flips the boolean, queues the change callback, and returns the new state. Raises a Luau error on any other kind.

update_options(options: { string }) -> ()

Dropdown-only. Replaces the option list with the supplied string array (non-string entries are dropped). The current index is clamped into the new range; if it shifts, the change callback is queued with the new index. Raises a Luau error on any other kind.