If () then
2.0 If () Then


Control Blocks


C blocks

The If () Then block is a Control block and a C block. The block will check its boolean condition. If the condition is true, the code held inside the block will run, and then the script involved will continue. If the condition is false, the code inside the block will be ignored and the script will move on (unlike in the If () Then, Else block). If the condition turns to false while the script inside the block is running, it will keep running until it has finished.

Before Scratch 2.0, this block was named If ().

In programming, one of the most important parts is "checking conditions". This block is the simplest way to do that. Therefore, the block is used practically everywhere. Some common uses:

  • Comparing values
  • Checking if input is given
  • Controlling objects
Community content is available under CC-BY-SA unless otherwise noted.