This skill helps an agent write Roblox DataStoreService code that neither loses nor duplicates player data. It looks for an existing persistence layer first, keys data by UserId, wraps every call in pcall and refuses to save after a failed load so defaults never overwrite real progress.
It includes patterns for loading on join, saving with UpdateAsync, saving on leave and in BindToClose, retrying only what is safe to repeat and building a leaderboard with OrderedDataStore. A gotcha list covers server races, yields inside UpdateAsync, throttling, stale reads and values that cannot be stored.
What You Get
- An eight-step workflow from finding the existing persistence layer to a join, change, leave and rejoin check
- Luau patterns for load on join, save with UpdateAsync, save on leave and BindToClose, a retry helper and an ordered leaderboard
- Shell searches that list every DataStore call, the shutdown handler and each SetAsync on a player key for manual review
- A gotcha list for overwritten data, cross-server races, side effects in callbacks, throttling, stale reads and non-serializable values
Common Use Cases
- Finding why player data was lost or rolled back
- Stopping items from duplicating after a teleport
- Fixing too many requests errors from saving on every change
- Building a top ten leaderboard
What Makes It Unique
The skill gates saving on a successful load, so a network failure is never mistaken for a new player. It explains why an UpdateAsync callback can run more than once and must not grant items, and it separates retry-safe writes from increments that could apply twice. Version notes record current request budgets and limits.
Under The Hood
The agent loads the SKILL.md and, when needed, a reference on sessions and limits. It runs ripgrep searches over the project’s source to list DataStore calls and edits Luau server scripts. The code it writes makes DataStore network requests when the game runs. For its final check it can use a connected Roblox Studio MCP server to play, change a value, stop, replay and read the value back; this needs a separate test place with Studio access to API services turned on, because Studio reads and writes live data. Without that server it asks you to do the join, change, leave and rejoin steps and report what you see.