Input

A text field. Commits on Enter, or when it loses focus.

The smallest input#

Luau
main:Input({
    Text = "Target player",
    Callback = function(text)
        target = text
    end,
})
Preview

My Script

v1.0

Filter

When it fires#

The callback runs when the field commits, which is pressing Enter or clicking away after changing the text. It does not run per keystroke.

Set FireOnBlur = false for a field that should only ever commit on Enter. Clicking away still keeps the text and still saves it; it just does not call back.

Luau
main:Input({
    Text = "Teleport to",
    Placeholder = "Username…",
    FireOnBlur = false,
    Callback = teleportTo,
})

Building it up#

Hint at what goes in it:

Luau
main:Input({
    Text = "Target player",
    Placeholder = "Username…",
    Callback = setTarget,
})

React as they type by reading the box yourself, which is the only way to get per-keystroke behaviour:

Luau
local filter = main:Input({ Text = "Filter" })
local box = filter.Instance:FindFirstChildWhichIsA("TextBox", true)
box:GetPropertyChangedSignal("Text"):Connect(function()
    applyFilter(box.Text)
end)

Every option#

OptionTypeDefaultWhat it does
TextreqstringThe label.
Callbackfunction(string)Called with the field's contents when it commits.
PlaceholderstringGhost text shown while the field is empty.
Defaultstring""Starting contents.
FireOnBlurbooleantrueCommit on losing focus as well as on Enter. Set false for Enter only.
FireOnStartbooleanfalseCall Callback once with the starting contents.
Stylestring"outline"Visual variant, matching the button styles: outline, filled, ghost or soft.
DescriptionstringA quieter second line.
IconstringAn icon shown before the label.
Savestring | booleanPersist under this key. true derives one from the section and label.
TooltipstringShown while the pointer is over the control.
DisabledbooleanfalseRefuses input and dims the control.
DisabledReasonstringShown as a tooltip while it is disabled.

A saved field calls Callback once with the value it restored. See Saving settings.

Methods#

MethodReturnsWhat it does
Get()stringThe current contents
Set(text)trueReplaces the contents and fires Callback
Set(text, true)trueReplaces the contents without firing Callback