PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Get Users to Input Text

Get Users to Input Text

Jun 23 2018, 2:02 AM PST

Problem

You want to read the current input (what the player has typed) from a TextBox.

Solution

Create a TextBox and use the TextBox/FocusLost event.

script.Parent.FocusLost:connect(
	function(enterPressed)
		if enterPressed then
			print(script.Parent.Text)
		end
	end
)

Discussion

The TextBox/FocusLost event fires when the user either clicks outside of the TextBox or presses the Enter key. In this case, we check to see if Enter was pressed and then print the value of the current TextBox/Text property of the TextBox.

Tags:
  • input
  • text