Check if text input is correct? 1.19.3

So I want to make a game where you click a button to hear a word and then you type what you hear in a text input. What script do I need to use to check what the user typed is correct or not and lead them to the right frame?
Thanks

1 Like

at the bottom right of the editor, there is a plus sign in the asset library. click that and you will get a menu of built-in assets. scroll down, and the very last item is a text input box. i don’t know how to help you from there, I have never used it before. I think there’s a variable called input that you can obtain somehow.

the other way is using prompt(). Learn about it here (W3Schools).

Hi @GiorgosFrappes,

what @awc95014 posted is correct. You can easily add a text-input that way.
You can retrieve the value of the input if you gave it a name by calling: MyName.value.
(Obviously MyName will be the name you gave the input.)
That will return a string, that you can compare to the value you expected, like this:

if ( MyName.value == "test"){ <do whatever you like>}

regards,

Paul

Thanks, I kinda get what you are saying. I do not understand how you “get” what was typed in the text input and make it into a variable though. Maybe you could explain this to me?

Hi,
well, Wick does that for you. The variable name will be the name you gave to the element, and if you put .value after that, you can access the value of that input element.If you want to store it separately, you can just go: var Thingy = MyName.value and the variable Thingy will contain the value of the input.