In this add-on, you'll create a variable
to store the fastest time.
To start, select make a variable.
Scratch has some variables already created,
like the timer used in the last step,
but this time you will make your own.
Name it something like fastest time, then select OK.
Drag the fastest time variable into the script's editor.
The fastest time variable will store
the shortest amount of time taken to finish the maze.
To set a new fastest time, tell the computer
to check if the value of the timer
is less than the lowest score.
Drag out an if statement...
And a less than operator.
Then, put the timer variable
and the fastest time variable into this operator.
This now reads, if timer is less than fastest time, then.
If the timer is less than fastest time,
then the value of the timer should become
the new fastest time.
Select a set fastest time to block,
and add the timer variable.
Now this reads, if the timer variable
is less than fastest time, then set fastest time
to the value of timer.
Now that you've coded this, add it to your program.
Check this if statement when the player
reaches the goal sprite.
Finally, set the timer to something really high.
Right now, the low score is zero
and it's impossible to get a time lower than zero.
Find the set fastest time to block
and change it to something like 50.
Click the block to test.
Now the player is ready to set a new fastest time.
Look at that.
Can you beat it?
Now it's your turn.
Create a fastest time variable,
set a new fastest time using the fastest time variable,
an if statement, a less than operator,
a set fastest time to, and two timer blocks.
Then, set the starting fastest time.