The GetFocusedTextBox event returns an Instance of the
TextBox currently selected by the player - such as when the player has selected a TextBox to input text.
Note: If the player has not selected a TextBox when this function is used, it will return nil.
UserInputService only runs client-side, this function will only work when used in a
The currently selected
This example prints the name of returned focused TextBox Instance, but only if a TextBox is focused. It checks for a focused TextBox every render step.
Note: It can be inefficient to check an event every render step. This example is meant only to show how GetFocusedTextBox can be used, and is not focused on efficiency or best use case.
local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") -- Get the Focused TextBox Instance RunService.RenderStepped:Connect(function() local FocusedTextBox = UserInputService:GetFocusedTextBox() -- Print name of the focused TextBox if FocusedTextBox then print("Name of Focused TextBox is", FocusedTextBox.Name) end end)