How to Make a Multiplayer Game on Scratch (Intermediate 8+)

POSTED ON AUGUST 27, 2021

Learn with Juni👋
Jumpstart your learning with Juni by getting exclusive content like our Juni's Guide to Learning in a Pandemic, subscribe for FREE!
Your Email

Make Multiplayer Game on Scratch

You know what's more fun than regular Scratch games? Multiplayer Scratch games! Today, we'll show you how to create your very own multiplayer games on Scratch.

What makes a multiplayer project different? It lets you play with other users, either on a single device or multiple computers all over the world!

Ready to level up your skills, Scratcher? Let's do it!

Why Make a Multiplayer Project?

As we already mentioned, a multiplayer video game allows you to play with someone else in the same room or connect with several other people around the globe. Cloud multiplayer functionality in Scratch is possible through the use of cloud variables.

Have you heard of the online multiplayer game called Minecraft? We thought so! With the use of encoding, game objects, and more, you'll be able to make a game similar to Minecraft or something completely different. The possibilities are limitless!

Besides being a lot of fun, Scratch programming language helps aspiring programmers 8+ to build their logical and creative abilities. Through game design, a kid coder can confidently prepare for more advanced game development.

From simple platformer games to complex multiplayers, you can build a strong foundation for multiple hobbies and careers. And with these skills, you'll be ready to work with many exciting platforms, including Python, Java, Android, GitHub, and more!

Basically, going from single-player to multiplayer game design will help you grow so much. And Scratch makes it user-friendly & simple to get started!

What You Need to Start

Scratch is a free, open-source programming language available to everyone!

If you haven't done so already, you can start a Scratch account today. All you need is a compatible device, brower, and web connection to begin your journey.

Creating a multiplayer Scratch game does require previous experience. If you're new, don't worry! Read our introduction to Scratch and get familiar with it. Once you've learned the basics, you'll be ready to build your own game and enjoy gameplay with others!

First time with Scratch? you can get up to speed with the following tutorials:

My First Scratch Project (beginners)

How to Make a Scratch Game (step by step)

How to Make a Platformer on Scratch (beginners)

You can also find inspiration from the most famous Scratcher on the platform, griffpatch. Check out some of his most popular multiplayer cloud games.

Let's now jump into making a multiplayer video game!

Multiplayer Project Tutorial

What to Know Beforehand

In this Scratch tutorial, we'll show you codes to make your own multiplayer video game!

At this point, you should be comfortable with Scratch blocks, sprites, and other game objects. If you need help, you can take a look at these handy tutorials:

How to Make a Platformer on Scratch (beginner 8+)

How to Make a 3D Game in Scratch (intermediate)

How to Make a Sprite Move Smoothly (intermediate)

Scratch allows you to make two types of multiplayer video games: local multiplayer and online multiplayer. Below, you'll find sections on each kind of project.

Local multiplayer lets you play with more than one person on the same computer. Online multiplayer lets you connect with multiple devices and multiple players, whether they are in the same building or a different country.

Ready to jump in? Let's go for it!

Create Local Multiplayer

Once you know how to make a game in Scratch, creating a local multiplayer is simple!

In this example, we'll assume two players are going to use the same keyboard to control the game. There will be two characters (or sprites), one for player 1 and another for player 2. executed.

How to make a multiplayer game in scratch tutorial screenshot

First, the above code is made for player 1.

How to make a multiplayer game in scratch tutorial screenshot 2

Next, the above code is made for player 2.

Since you'll be sharing the same keyboard, each player is assigned different controls. Player 1, for this example, will be on the left side (using the letter keys). Player 2 will be on the right side, using the arrow keys to move their character.

Depending on your game, the scripts can be coded differently.

Create Online Multiplayer

Okay, so now we know how to make a local multiplayer. Time for an online version!

Scratch makes it easy to connect with other players from all over the world through cloud variables. You can read more about the function and more on Scratch Wiki.

Keep in mind that new Scratchers cannot use this functionality because of restrictions. You must get full Scratcher status in order to use cloud data.

This coding is more extensive. Don't fret! Take your time. Before you know it, you'll be playing with others from other countries in your own game!

(Note: there's currently a 256-character limit on cloud variables in Scratch 3.)

Variables

Before we start block coding for a basic multiplayer, there are several variables that must be created. These variables are as follows:

'Cloud check': Used to confirm two players are connected.

'Player1 check': Confirms if player 1 is active.

'Player2 check': Confirms if player 2 is active.

'Player1 coords': Send player 1 coordinates.

'Player2 coords': Send player 2 coordinates.

'Local player1 check': Checks if non-cloud player 1 is on.

'Local player2 check': Checks if non-cloud player 2 is on.

'Player ID': Indicates what character you're controlling.

Cloud Script

How to make a multiplayer game in scratch tutorial screenshot 3

Okay, so we've created our variables. Now it's time to build our cloud script!

The 'wait 2 seconds' block helps ensure the game is connected to the cloud.

There are two sets of block code, one for player 1 and one for player 2.

This coding checks connection.

Once all the blocks and variables are set up correctly, you'll be able to test cloud connection!

Player 1 Script

How to make a multiplayer game in scratch tutorial screenshot 4

Here, we have the script for player 1. Assign it to the correct sprite.

The handy part is that once you've created this script for the 1st player, you can duplicate it and adjust for player 2. This makes the process a lot easier!

Player 2 Script

How to make a multiplayer game in scratch tutorial screenshot 5

This above code is for player 2. It's made up of variables transferred from player 1.

Again, make sure to assign this script to the correct sprite. You'll need to assign the proper Player ID ('Player ID = 2’) plus variables 'player2 coords' and 'player2 check'.

Errors Script

How to make a multiplayer game in scratch tutorial screenshot 6

This above code tells players if there are any errors (including not being able to connect).

Congrats, you've done it! Continue to practice. With Scratch, it's easy to make your own games. Unleash your creativity and let your imagination fly!

With this tutorial, you can level up your skills and make amazing multiplayer worlds. Plus, it allows you to play with other users! As you progress, you'll be able to work with some of the best 3D modeling tools (including Unity, Unreal Engine, and Blender).

Great Work! Now Keep Exploring

Awesome job, Scratcher!

Now, you can build your own Scratch multiplayer game. Scratch makes it friendly & fun for kid coders. Continue to level up your skills, discover Scratch multiplayer projects, and share your game projects with the Scratch community!

Read about our online coding classes for kids, or contact our Admission Team to learn which courses are best for your student’s coding journey. You can also read more about how we use Scratch to teach coding.


Related Reading