How to Use Scratch Cloud Servers: A Beginner’s Guide
Ever wondered how some Scratch projects keep track of scores or player names even after you close the editor? That magic comes from Scratch cloud servers, which store cloud variables that persist across sessions. If you’re new to the platform, this guide will walk you through the basics, show you how to set up cloud variables, and share tips to keep everything running smoothly.
Understanding Scratch Cloud Servers
Scratch cloud servers are a set of servers operated by the Scratch team that host special variables marked as “cloud” in a project. Unlike ordinary variables that reset when a project stops, cloud variables are saved on the server and can be read or written by anyone who runs the project, enabling simple multiplayer features and leaderboards.
These servers are not a full‑blown backend like a traditional web server; they only handle the storage and retrieval of cloud variable data. The rest of your project still runs locally in the browser, so the performance impact is minimal.
How Cloud Variables Work Behind the Scenes
When a Scratch project includes a cloud variable, the editor automatically prefixes the variable name with a ☁️ icon. Whenever the script changes that variable, the new value is sent to the cloud server via a secure WebSocket connection. The server then broadcasts the updated value to every other instance of the same project that is currently online.
This real‑time syncing means that if two players are playing a racing game, each can see the other's score instantly. The server also timestamps each change, which helps prevent conflicts when multiple users try to write to the same variable at the same moment.
Setting Up Cloud Variables in Your Project
1. Open the Scratch editor and click the “Variables” category.
2. Choose “Make a Variable,” give it a name, and tick the “Cloud variable (☁️) for all users” box.
3. Use the usual “set” and “change” blocks to manipulate the cloud variable inside your scripts.
That’s it—Scratch takes care of the networking for you. Just remember that cloud variables can only store numbers, not text strings, so you’ll need to encode any text you want to share (for example, using character codes) if you really need to.
Best Practices for Using Cloud Servers
Keep values simple. Since cloud variables accept only numeric data, store scores, timestamps, or IDs rather than complex structures. If you need to transmit more data, consider splitting it across several variables.
Validate inputs. Anyone can write to a cloud variable, which means malicious users could try to flood the server with huge numbers. Adding sanity checks—like clamping scores to a reasonable range—helps keep your game fair.
Throttle updates. Sending a value change every frame can overload the server and cause lag. Update the cloud variable only when the value actually changes, and use “wait” blocks to space out rapid updates.
Common Limitations and Workarounds
Cloud servers impose a rate limit of roughly one update per second per variable. If your project needs faster updates, you can distribute the load across multiple variables or design the game so that only critical data is stored in the cloud.
Another limitation is the 10 MB total storage cap per user across all of their cloud variables. For most small games this isn’t an issue, but if you plan a large leaderboard, consider resetting older entries or archiving them outside Scratch.
Because cloud variables are public, anyone can inspect their current values using the “See inside” option on a project page. If you need to hide sensitive information, you’ll have to encrypt the data yourself or avoid storing it in the cloud altogether.
Extending Functionality Beyond the Basics
For creators who want more than just simple numeric syncing, external services can fill the gap. By using Scratch’s “Extensions” feature, you can connect to APIs via the “HTTP” or “Websocket” blocks (available in the experimental extensions). This lets you pull in data from a personal server, store JSON objects, or even integrate with Discord bots for richer multiplayer experiences.
Keep in mind that external calls are subject to Scratch’s content‑filtering policies, so anything you send or receive must comply with the community guidelines.
Frequently Asked Questions
Can I use cloud variables to store player usernames?
Not directly, because cloud variables accept only numbers. You’d need to convert each character to its ASCII code and store the sequence across several variables, which can be cumbersome.
What happens if the Scratch server goes down?
Your project will still run locally, but any attempt to read or write cloud variables will fail until the service is restored. It’s a good idea to design fallback logic that handles missing data gracefully.
Are cloud variables secure?
They are transmitted over encrypted connections, but the values are publicly visible to anyone who inspects the project. Treat them as public data, not as a secret storage solution.
Do I need a Scratch account to use cloud variables?
Yes. Only logged‑in users can create or modify cloud variables, which helps the platform track abuse and enforce rate limits.