Get User Text Input
Get User Text Input
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
.
Make sure you put this code inside of a `LocalScript` inside of a `TextBox`.