Skip to content

Ask the player a question

Use askAndWait to show an input box on the stage, then read what the player typed with getAnswer.

whenGreenFlag(() => {
askAndWait("What is your name?");
say("Hello, " + getAnswer() + "!");
});

The sprite pauses and waits for the player to type and press Enter. Once they do, getAnswer returns whatever they typed so you can use it anywhere.

  • whenGreenFlag โ€” run code when the green flag is clicked
  • askAndWait โ€” show an input prompt and wait for the playerโ€™s answer
  • getAnswer โ€” get the most recent answer from askAndWait
  • say โ€” show a speech bubble
  • move โ€” move forward by a number of steps
All recipes