"Answer" redirects here. For the information that this block reports, see Answer (value).
Category Sensing
Type Reporter
Introduced in 13Feb09 (1.4 alpha)

The answer block is a sensing block and a reporter block. The block returns the most recent text inputted with the Ask () and Wait block. When nothing has been inputted yet, the value will be nothing. It was introduced in 13Feb09 of Scratch 1.4 alpha.

This block can be displayed as a Stage Monitor.

Example Uses

As this block stores inputted text, it is very useful where a script has to refer to what has been inputted. For example, there are chat bots that allow the user to input their name. If the script must access their name, the answer block can be used.

Some common uses for the answer block:

  • Retrieving information inputted by the user
ask [What's your favorite color?] and wait
say (join (answer) [ is my favorite color too!] )
  • Storing user input from the ask () and wait block
when green flag clicked
ask [Which level do you want to play?] and wait
set [level v] to (answer)
broadcast (join [start level ] (level))
  • Checking if an answer is correct
when green flag clicked
ask [What is 30 + 9?] and wait
if <(answer) = [39]> then
    say [Correct!]
    change [score v] by (1)
    say [Incorrect]
    change [score v] by (-1)

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.