Using in If Statements

Topic

Using in If Statements

Topic Progress:

You can use the numbers stored in a variable within an if statement to get code to react in a certain way a good example of this is lives where you want the game to stop once lives equals 0.

Drag the orange rounded rectangle with the name of your variable out onto an equals block found inside the green operations tab as shown in the GIF below.

We can then put code inside of the if statement so it will only happen if the variable is a certain value.

Try out the code on the link below which is a simple lives counter where you lose a life when the sprite is clicked.

https://scratch.mit.edu/projects/348402210/editor/

@

Not recently active