Overview
Ledger saves Roblox player data safely. Every change is saved once, and every answer tells you what happened.
Ledger is a DataStore library for Roblox. You describe how your data is allowed to change, and Ledger saves each change exactly once, even when a server crashes or two servers change the same player at the same moment.
local Ok, Why = PlayerStore:Edit(Player.UserId, { Kind = "AddGold", Amount = 50 })
if not Ok then
warn("Couldn't add gold:", Why)
endtrue means the change is saved. Anything else is a reason that says what happened, and Answers says what to do about each one.
What it's for
| Job | What you get |
|---|---|
| Player data | Loaded when they join, saved while they play and when they leave. |
| Developer products | A purchase is granted once, even when Roblox sends the receipt again. |
| Trades | Both players change, or neither does, across servers and offline. |
| Guild banks and shops | Data many servers change at once, without losing a change. |
| Auctions and markets | Gold held safely until the auction ends or the item sells. |
| Limited items | A fixed number sold across every server, never one too many. |
| Global counters | A number every server adds to, like total boss kills. |
| Updates | Change the shape of your data without breaking old saves. |
| Deleting data | Erase a player's data when Roblox asks you to. |
What it isn't for
- Client scripts. Ledger runs on the server. Calling it from a client throws.
- Searching. You can't search your data.
Store:Keys()lists every key, or the keys that start with a prefix, a page at a time. - History. Ledger keeps no log of what changed. Roblox keeps a version of a player's data for each hour it was written, for 30 days:
Store:Versions(Key)lists them andStore:PeekVersion(Key, Version)reads one.
Where to start
The Learn pages build one game in order, starting with saving a player's gold. Each page adds one thing, and every sample is complete and type-checked. Start at the top and read them in order.
Next: Getting started