How do I make pressing enter while typing/active on a textbox do something?

I’m making a difficulty chart obby, and I have a thing where you can go to any previous stage by entering the stage number in a textbox and pressing enter.

image

I’m not worried about the arrows, I already know what to do for those. I’m asking about the TextBox.

Is there like an event or something for pressing enter while typing/active on a textbox? If it is, what is it?

If not, then how do you do this?

The first argument passed to the TextBox’s .FocusLost event is a boolean which reflects whether enter was pressed or not.

1 Like
local Script = script
local TextBox = Script.Parent

local function OnTextBoxFocusLost(EnterPressed, InputObject)
	if EnterPressed then
		--Do code.
	end
end

TextBox.FocusLost:Connect(OnTextBoxFocusLost)

The first argument passed to callback functions connected to a text box’s ‘FocusLost’ event/signal is a Boolean value indicating if the enter key was pressed. The second argument is an ‘InputObject’ value.
https://developer.roblox.com/en-us/api-reference/event/TextBox/FocusLost

3 Likes