- Good job so far! Now let's make your game more challenging.
- Let's add a timer that counts down to 0
- Start by making a new variable and name it timer
Bot Builders : Train Your Robot
Add a timer
- Let's make a new script block to manager the timer.
- Start by resetting the timer to 30 when you start the game.
- Add the code block to your robot.
- What we want to do is to decrease the time by 1 every second.
- To do this, we'll be using a special type of loop.
- Go to the control blocks and attach
repeat until <>
- This control block repeats the script inside until a certain condition.
- Our condition is that the loop will stop until the timer variable is 0.
- Go to the Operators blocks, and attach
<  =  >inside.
- We can use this operator to compare
wait (1) secsinside repeat until <>.
- Afterwards, decrease the time by 1 with
change [time v] by (-1)
- Now try clicking the green flag icon and check the time value if it changes every second.