GuideScripting
Save player progress: leaderstats and DataStores in Luau
One commented server script that shows coins on the leaderboard, loads them when a player joins and saves them when they leave, on a timer and when the server shuts down.

On this page
Every game that asks players to come back needs two things: a number they can see go up, and that number still being there tomorrow. In Roblox those are leaderstats (the stats in the player list) and DataStores (saved data). This guide builds both in one server script, explains every line that matters, and lists the limits you will hit later.
What you will build
- A Coins stat in the player list for everyone in the server.
- Coins loaded when a player joins and saved when they leave, every three minutes, and when the server shuts down.
- A safe failure: if loading fails, the player is asked to rejoin instead of starting from zero and overwriting their save.
Before you start
- Publish the place. DataStores only work in published games.
- In Studio, open File > Experience Settings > Security, turn on Enable Studio Access to API Services, and save.
How leaderstats work
Roblox shows a stat in the player list when a Folder named leaderstats (all lowercase) is parented to the Player object, and it holds value objects such as IntValue, NumberValue or StringValue. Stats appear in the order you add them. To force an order, add a BoolValue named IsPrimary (set to true) or a NumberValue named Priority (higher shows first) inside a stat.
The script
Add a Script (not a LocalScript) to ServerScriptService and name it PlayerData:
Related guides

GuideGrowth and marketing
The first five minutes of a Roblox game
What a new player has to see, do and want in their first session, which of Roblox's ranking signals it decides, and how to measure each step with funnel events.
5 min readChecked Nov 16, 2026

Guide