Random numbers
Section 7: Variables and randomnessLesson 7.2 · ⏱ 6 min
Random means a number you can't guess. Games need it so they don't play the same way every time.

🖥️ What happens on the stage?
Robo jumps to a new random place every second.
💡 Tip
The block pick random (1) to (10) gives you a random number. Put it inside wait to make the waiting random too.
📌 Another example: moody Robo
pick random chooses a different number every time: a random size from 50 to 150, and a random place.



✍️ Practise
Make Robo turn a random angle (from 0 to 360) every time you press space.
✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
🎯 Challenge yourself
Easy
Make Robo say a random number from 1 to 10.
👀 Show the solution🙈 Hide the solution


Medium
Make Robo glide 3 times to a random x (from -200 to 200), with y staying 0.
👀 Show the solution🙈 Hide the solution


Hard
Roll a dice into a variable d: if it is 6 he says “I won! 🎉”, else he says “I rolled” and the number.
👀 Show the solution🙈 Hide the solution



