Collapse Sidebar


The TextBoxFocused event fires when a gains focus on a TextBox - typically when a client clicks/taps on a text box to begin inputting text. This also fires if a text box focus is focused using TextBox/CaptureFocus.

For example, the code below prints the the name of the TextBox focused when the event fires.

local UserInputService = game:GetService("UserInputService")

function TextBoxFocused(textbox)


It can be used alongside UserInputService/FocusReleased to track when a text box gains and loses focus.

As this event only fires locally, it can only be used in a LocalScript.

See also

  • UserInputService/GetFocusedTextBox
  • TextBox/Focused
  • TextBox/FocusLost


Name Type Default Description

The TextBox that gained focus

Code Samples

Modifying a TextBox on Focused and FocusReleased

This example adjusts the GuiObject/Transparency|transparency of TextBox|TextBoxes when they gain and lose focus using.

When a text box UserInputService/TextBoxFocused|gains focus, it’s transparency deceases. When a text box UserInputService/TextBoxFocusReleased|loses focus, it’s transparency increases. This is similar to how the default chat window increases and decreases transparency when a user starts and stops interacting with it.

In order for this example to work as expected, it should be placed in a LocalScript.