The if.then.else statement is fairly complex, but by breaking it down step-by-step we will try to simplify it.

In the example below we'll be adding an if.then.else statement to tell a button to pause music if the music on otherwise turn on the music.

1. First make sure you have a when.Click box to add the if.then.else box to.


2. Locate the If.then.else block. You can find it in the control tab the blocks.

*Note there are two options, we will be selecting the first option for this project. Notice that the puzzle pieces connect differently. The one we want (the first) does one of two actions. The second one produces one of two values. You will see its use in later examples.

*Note how the two blocks connect differently (this one has a tab on the left). The second if.then.else block is a connecting piece.

3. Drag the If.then block onto the viewer.

***Note that currently it is only an If.then block now, but this block with blue square is an adjustable block, so we turn it into an if.then.else block.


4. Click on the blue square in top right hand corner of the if.then block.


You should click on the else block and drag it to the right into the blank if-block.


5.You could actually have a lot of choices. Look at the statement below. It could help you pick between one of six desserts based on cost.


***For now you don't need to worry about such if.then.else blocks, but keep in mind for future projects that more involved statements can be made.

6. Now it is time to add arguments to the if.then.else statements. You want to know if the player is already playing. I named my player "FridaySong" as that is the song it is playing. Yours will be named something different. Click on you player to find operations dealing with the player. Below are the conditions and statements that we will be adding.

arguments for IF.png

The .isPlaying condition asks if the player is currently playing.

The call.Start statement tells the player to start playing.

The call.Pause statement tells the player to pause playing.

7. Now we need to attach the conditions and statements to the if.then.else block.


This statement says, If the song isplaying, then Pause, else (if it's not playing) then start it.

8. Now we need to add the if.then.else block to our when.Click block.


9. Finally, we can add a final volume argument to the when.Since the volume is always set to 25, this isn't very interesting. You can imaging slowing making the volume louder or softer.

Screen Shot 2016-05-04 at 9.03.03 PM.png