Script in Scratch Programming
Last Updated :
21 Jul, 2021
Scratch is an event-driven programming tool developed by the Lifelong Kindergarten group at MIT in the media lab to create your own games, visual programs, interactive stories using building blocks. To create a program in Scratch we do not need to write code to perform operations. In Scratch, the operation is performed just by drag and drop, similar to visual basic. It is a very good tool to start your programming.
What is Scratch Script?
Scratch is visual programming to create your own games, stories, and animations. The set of instructions that is used to program in Scratch is called a script. It is a stack or collection of blocks that connect with one another. The blocks of instructions are nicely ordered to perform a specific task, as they determine to interact sprites. It’s a good way to add comments in the script to define what is being done. In Scratch, a sprite is an actor or main character of the program or a graphic element that performs all the activities that are given in the script.
Use of Scratch Script:
- To create a Scratch script, just simply drag blocks out of the block palette and assemble them.
- To disassemble the blocks from the script, drag them apart from the scripting area.
- To remove a script from your program, select the script and press delete.
- To execute a single script just click on it.
Structure of Scratch Script:
- Starting a script such as a click the green flag to start.
- Add to the end of a script.
- Ending of a script
- Essential to fit inside other blocks.
- Contain other blocks.
Script Area:
Script area is present on the right side of the programming palette, here the scripts are assembled. From the programming palette or block palette, blocks are dragged to the script area to store and execute in a project. Or you can stack them together to create a script. When you right-click on the script area you will get the following options: Undo, Redo, Clean up blocks, Add comments, and Delete blocks.

Script Fragment:
In a Scratch, a script fragment is known as an incomplete script, which means a script that has no hat block. in normal execution, script fragments will not run because there is not a hat block available to start the code. They are generally used to create thumbnails because it has the ability to show sprite that is not visible while normal execution of the program. They are generally stored in the backpack(it is a special feature that stores user’s projects) and easily appear on a hat to run the code. Every block present in the editor is the script fragment.
Example 1 – Moving Logo
In this example, we will create a scratch program to move the logo 30 degrees clockwise.
Procedure:
Step 1: Open scratch editor.
Step 2: Drag the “when space key pressed” block from the event block on the script.
Step 3: Now drag the “forever” block from the event block and place this block under the “when space key pressed”.
Step 4: Now drag the “wait” block from the event block and place this block under the “forever” block.
Step 5: Now drag and place “turn degrees” block from the motion block under the “wait” block. Now change the value from 15 to 30 degrees clockwise.
Step 6: Now run the script.

Below is the execution of the above procedure:

Example 2 – Moving cat using arrows with sound
In this example, we will create a Scratch program to better understand the Scratch script. Along with an example, the live project link will be attached and also used through a webpage using an iframe. This program is designed in Scratch with some simple scripts. We will understand every aspect of this program.
Step 1: Open scratch editor.
Step 2: First, we used an event, i.e., “When green flag” from the events section. It declares that our program will be executed when we click on the green flag (execution button).
Step 3: Drag a forever loop from the controls section. It is similar to the for loop like other programming languages. The iteration of the program is done by this forever loop.
Step 4: In the next step, we take four conditions according to the arrow to control our program. It defines the sprite (cat) will be moved-in a specified direction with a meow sound.
Step 5: Now run the script.

Below is the execution of the above procedure:

Similar Reads
Variables in Scratch Programming
Scratch is a high-level visual programming language tool that interacts with users through diagrams and blocks that have the basics of a program inbuilt in it. Scratch is used to make interactive programs especially for kids using the block kind of interfaces so that they can easily learn languages
7 min read
Introduction to Scratch Programming
Scratch is a block-based visual programming language that can be used to make interactive games and animations. It has a huge online community where you can share, discuss and view scratch programs. The objective behind the development of Scratch is to help children(mostly) to think creatively, work
3 min read
Introduction to Scratch Programming
Scratch is an event-driven visual programming language developed by MIT. In Scratch, we can create our own interactive stories, games, and animations using building blocks. In this platform, we do not need to write code to perform operations, things are done just by drag and drop, just like visual b
5 min read
Basics of Scratch Programming
Scratch is a programming language. Programming language is meant that a means of communicating with the computer, so as to give some instructions for it to perform. Programming in Scratch is very easy, including animation and games. It is a very useful tool for young kids or creators to learn and im
6 min read
What is Iteration in Scratch Programming?
Scratch is a high-level visual programming language tool that interacts with users through diagrams and blocks that have the basics of a program inbuilt in it. Scratch is used to make interactive programs especially for kids using the block kind of interfaces so that they can easily learn languages
7 min read
What is Conditional Programming in Scratch?
Scratch is a high-level visual programming language tool that interacts with users through diagrams and blocks that have the basics of a program inbuilt in it. Scratch is used to make interactive programs especially for kids using the block kind of interfaces so that they can easily learn languages
5 min read
Ask(), Wait() and Answer() Block in Scratch Programming
Scratch is a high level visual programming language tool that interacts with users through diagrams and blocks that have the basics of a program inbuilt in it. Scratch is used to make interactive programs especially for kids using the block kind of interfaces so that they can easily learn languages
4 min read
School Programming
This page is designed for beginners in programming language, especially school students. It has the following sections. Introduction to Programming LanguagesLearning a Programming LanguageProgramming Problems and SolutionsPractice ProblemsRecent School Coding ArticlesRecent School Coding Practice Pr
7 min read
Hello World in R Programming
When we start to learn any programming languages we do follow a tradition to begin HelloWorld as our first basic program. Here we are going to learn that tradition. An interesting thing about R programming is that we can get our things done with very little code. Before we start to learn to code, le
2 min read
Batch Script - Arrays
An array is a collection of elements of the same data type. The arrays are not explicitly defined as Batch Script types but can be used. The following items need to be noted when the same members are used in Batch Script. Each aspect of the same members needs to be defined by a set order.A âforâ loo
5 min read