Saving Games

by Jon (Updated on 2014-01-26)

Saving progress is a fundamental part of most games. This article explains how our saving system works.



  • How Saving Works
  • How To: Saving and Loading
  • Detecting Failure
  • Where is Data Saved?
  • Challenge: Checkpoints

How Saving Works

Saving in Stencyl uses a game’s Game Attributes to save data.

Note: Need a refresher on Game Attributes? Read our article on Game Attributes.

All you have to do is structure your game such that anything you want to save is stored in Game Attributes.

Similarly, loading a save file will completely overwrite the game's current Game Attributes and replace them with the values of those in the save file.

Saving and Loading are nearly instant - these operations will not hang your game. That said, Saving and Loading are blocking operations in the sense that nothing else will happen until those operations are complete.

Common Question: Suppose the player is playing your game for the first time. How do you know this? You could create a game attribute called "first time" that is initially set to true. When you save the game, it's always set to false.


How To: Saving and Loading

Saving and Loading involve just use these two blocks. (Game > Saving)

When do you load a game? It's up to you, but most like to do it in the game's first scene.

What do the save succeeded and load succeeded blocks do? That's detailed next.

Detecting Failure

Occasionally, a player will be unable to save, usually due to restrictive security settings.

If saving/loading fails, you can detect this and use the “save succeeded” and “load succeeded” blocks react appropriately, such as showing an error message.

To use them, just drag them out as pictured and use them within an if-block.

Warning: Don't use the save/load succeeded blocks outside the scope of the save/load wrapper, or you'll run into a compile-time error.


Where is Data Saved?

Flash games use Local Shared Objects. That is to say, it's stored by the browser indefinitely until cleared out.

Mobile games store save data directly on the file system but within the confines of the app's sandbox. This data is not deleted until the game itself is deleted (and settings/data are explicitly told to be removed). At this time, it isn't possible to specify custom save locations or write out arbitrary data at runtime.



  • Saving is based on Game Attributes.
  • Loading will overwrite all Game Attribtues.
  • Saving/Loading is an instant operation.

Challenge: Checkpoints

Many games use a checkpoint system, a system in which reaching a certain part of the level will guarantee that, if a player dies, the player can continue from that checkpoint, rather than starting from the beginning.

Create a simple checkpoint system for your game, such that even if the player exits out of the game, he’ll begin from the last checkpoint he reached.

Disclaimer: All articles are geared towards Stencyl 3.0 and above. Use comments to provide feedback and point out issues with the article (typo, wrong info, etc.). If you're seeking help for your game, please ask a question on the forums. Thanks!


Hi i'm tryng to do a save when pressed ctrl S but i want to when my characters dies it will revive in the same location i have doed ctrl S any know how?

-1 7 months ago
to make checkpoint, create a game attribute, name it as checkpoint or anything else, and make a region in different parts of your game that you want to be a checkpoint. so, when de player actor reach a sensor, set the attribute to a number related to that specific region, and call the save propertie.

on the load event, program to the actor be created at the checkpoint that your saved game attribute says that is the last checkpoint reached.

0 1 year, 1 month ago
The article doesn't give an explanation as to how to set up a proper checkpoint system.
1 1 year, 2 months ago
I sometimes get a warning saying "WARNINGS: There was a problem binding to the shared object data from FlxSave."
Then I get several warnings that bind() must have been called before calling write().

The article should probably cover some troubleshooting...

0 1 year, 8 months ago
nice...hve to improve...2 nxt Level..!!!!!
0 1 year, 9 months ago
my confusion is not the saving of the attributes its the loading and initial setting of the players stats before the first save. How do you tell the player he has a game attribute value of 5 when the player starts the game and it not change the value during the save? Put that initial game attribute value before the player loads the game, like on the start screen?
1 2 years, 9 months ago
Nice, this works!
0 2 years, 9 months ago
There's no specific place you have to put these code blocks. You can make the game save at any time you want; when something happens, when a button is clicked, and so on.

If you don't understand how to implement code blocks, you should read earlier sections of this wiki. Once you understand the basics of Stencyl, this section will make more sense.

2 3 years, 2 months ago
As always, there is exactly zero help in this.
You just again tell me, that my car has 4 wheels and 4 seats, but you don't tell me, how I can drive it...

-2 3 years, 2 months ago
this only shows me what block i need to use i dont know where to put it how to use it in design mode so this is pretty much a tease
0 3 years, 3 months ago

Sign In to Comment