Tutoring

Learn

Resources

How to Run a Scratch Program? – Execute Scratch Code

Updated By

Reviewed By

scratch games
Image

Run a Script in Scratch Programming: Scratch is built essentially for children who are interested in coding and game development. It is a visual programming language that enables children to make different types of fun and colorful projects, which include animations, games, stories, and much more!

The collection of code blocks that interlock with each other to perform a certain action or story or game is called a Script. A project in Scratch is usually referred to as referred to a Script. The purpose of creating a project or script in Scratch is to execute or run it. In this blog, we will discuss how to do that.


This is Chapter 4.1 in the
Advanced Scratch Tutorial


Which Button Is Used to Run the Script?

The “green flag” button is used to run a script in Scratch programming. The button is located just above the stage area, next to the “red button”. The “red button” is used to stop the script. To run the script by clicking on the “green flag ” button, you have to add the code block from the “Events” category. Drag and drop the “when green flag clicked” from the “Events” category in the Block palette.

green flag in scratch

Add other code as per your objective. For example, if you want to turn your sprite 15 degrees, then first add the “when green flag clicked” from the “Events” category, and then the “turn 15 degrees” code block from the “Motion” category and click on the “green flag” button on top of the stage area and you will see the sprite turning 15 degrees every time you click on the “green flag” button.

How to Run a Script in Scratch Programming?

Executing a command and running your project on Scratch is easy to understand, let us understand how to run a script in the Scratch program with an example.

Step 1- Login into your Scratch Account

Firstly, you need to log in to your Scratch account and if you don’t have an account on Scratch then you need to create one.

Step 2- Create a New Project

After login in, click on “Create” on the upper left side. You’ll be taken to the coding area where you have put codes from the “Block palette” on the left side, as shown in the image below. “Stage area” is where the actions of the sprites are displayed and “Code area” is where you have to drag and drop the code blocks from the”Block palette”. The important step here is to have an idea of what you want to create.

The ”cat” icon represents sprites which is what characters are called in Scratch. You can choose the default cat sprite or choose a different sprite by clicking the sprite icon in the stage area.

The “green flag” icon is an important feature as it is clicked to run the code and the “red button” icon is to stop the game.

Step 3- Choose your Sprite

Choose your sprite. On Scratch, the characters in the projects are called “Sprites”. Scratch has many pre-designed sprites available to use. You can also create your own sprite. After choosing your sprite you have to now add codes so that they can function.

Step 4- Drag and Drop the Code Blocks

What makes Scratch such an easy-to-grasp programming language is its drag-and-drop feature. The codes are already in the block palette in form of blocks and all you need to do is drag and drop them in the code area. As per your project’s objective drag and drop codes that you need to make let your sprite have some movements in order to complete the objective of the project.

If you have added more than one sprite then you have code for each one of them separately by clicking on the particular sprite.

Step 5- Run the Scratch Project

After you have dragged and dropped the code blocks and arranged them strategically to make them move or perform some action according to your objective, click on the “green flag” icon to run the project. Take the given image as an example,

run script in scratch

Here, the objective was to turn the cat in 15 degrees. So after adding the code blocks, “when green flag clicked” and “turn 15 degrees”, the green flag icon located just above the stage area is clicked to run the project and the cat turns 15 degrees every time the “green flag” icon is clicked. The “green flag” icon helps run the code.

Step 6- Save your Project

After you have structured your codes strategically to make the characters move and have created your desired project, save it in your Scratch account. You can do that by clicking on the “File” icon on the upper right side, next to your profile icon. It’ll take you to “My stuff” where all your projects will be saved.

FAQs on Run Script in Scratch Programming

Q 1: What is a Script in Scratch programming?
A 1: A project, like games or animations, that requires a set of codes to run it is called a Script.

Q 2: Which button is to be clicked in order to run a script?
A 2: The “green flag” button, at the top of the Scratch stage, needs to be clicked in order to run the Script.

Q 3: Which button to click to stop the Script?
A 3: The “red button” next to the “green flag” button needs to be clicked in order to stop the Script.

Q 4: How to run a Script in Scratch?
A 4:
Open the Scratch editor. Drag and drop the code blocks from the block palette and strategically stack them on top of each other in order to give the Sprite some movement. After you are done with coding, click the “green flag” button, just above the stage area, to run a Script in Scratch.

Q 5: What is a block palette in Scratch?
A 5: The Block palette contains all the block code blocks that are required to run a Script in Scratch.

Q 6: How do you run a program in Scratch?
A 6: You run your program by adding the code block “when green flag clicked” from the events category of the block palette and after you are done adding your other code, you simply click on the “green flag” button located on top of the stage area and your project will run.

Q 7: Which option allows you to start a Scratch script?
A 7: The “green flag” button above the stage area allows you to start a scratch script.

Q 8: Every script must begin with which block?
A 8:
A Hat block is used to start a script.

Q 9: What is the name of the default sprite in Scratch programming?
A 9:
A sprite is referred to as a character in the Scratch programming. The default sprite in Scratch programming is Cat. You can also change the default sprite.

Q 10: Where is the script area in the Scratch editor?
A 10:
The script area is where you drop the block codes and arrange them to run the script. the script area is located on the right side of the project editor.

Q 11: How can we run the script in Scratch?
A 11:
After you have completed your project, click on the “green button” just above the sprite pane. This will run the script for your Scratch project.

Q 12: What is a script in Scratch?
A 12:
A script in Scratch is a set of instructions that is used to program Scratch projects.

Though Scratch programming is a great fit for a primary school computing curriculum, it’s always best to challenge the more able students and provide something new to break up the monotony of using the same software for several years.

Get 1-on-1 online Scratch classes
Don't forget to share this post!
tutor Pic
tutor Pic

First Lesson Free

No Credit Card

No Subscription