/roblox-dev:roblox-datastoresfrom roblox-dev
Guides safe Roblox DataStore usage with retry/backoff, session locking, autosaves, BindToClose, and schema migration. Use when writing or reviewing player data persistence code.
Ships in roblox-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Players quit games forever over lost progress. DataStore calls fail routinely
(throttling, outages, shutdowns mid-write), and naive save code will
eventually dupe items or wipe saves. Treat persistence as a system, not a
SetAsync call.
pcall with retry + exponential
backoff. No exceptions.UpdateAsync, never GetAsync + SetAsync.
UpdateAsync receives the latest stored value and lets you transform it
atomically; Get+Set races against other servers and against yourself.game:BindToClose.
All three. Servers die without warning; BindToClose gives you ~30
seconds to flush everyone.For production games, prefer ProfileStore (successor to ProfileService) — it implements session locking, retries, and release semantics correctly. These patterns below are what such a library does for you; implement them by hand only when you have a reason to.
--!strict
local function withRetry<T...>(attempts: number, fn: () -> T...): (boolean, T...)
local delaySeconds = 1
for attempt = 1, attempts do
local results = table.pack(pcall(fn))
if results[1] then
return true, table.unpack(results, 2, results.n)
end
warn(`DataStore attempt {attempt}/{attempts} failed: {results[2]}`)
if attempt < attempts then
task.wait(delaySeconds)
delaySeconds = math.min(delaySeconds * 2, 16)
end
end
return false
end
Budget awareness (limits as documented in late 2026):
60 + 40 × players requests per
minute. UpdateAsync spends a read and a write. Check
DataStoreService:GetRequestBudgetForRequestType(...) before non-critical
writes and defer when low.On load, atomically claim the profile via UpdateAsync:
JobId + timestamp into
a lock field and proceed.UpdateAsync writes data AND clears the lock.PlayerAdded ──▶ claim lock + load ──▶ in-memory profile (single source of truth)
│ gameplay mutates ONLY this table
├─ autosave every 30–60s (staggered per player)
PlayerRemoving ─▶ final save + release lock
game:BindToClose ─▶ final save + release for EVERY remaining player, wait for all
Rules that fall out of this:
player joins → offset = hash(UserId) % interval) so 50
players don't all save on the same tick.BindToClose, save players in parallel (task.spawn per player), then
wait until all finish or ~25s elapse. In Studio, skip the wait
(RunService:IsStudio()), or stopping playtests becomes painful.UpdateAsync's transform cannot yield and may run several times
(Roblox re-calls it with the newer value on conflict). Keep it pure: no
task.wait, no granting items, no remote fires inside it. Do side effects
after the call succeeds.nil from an UpdateAsync transform to abort the write (e.g. the
stored data is newer than what you have).Data outlives your code. Version it from day one:
local CURRENT_VERSION = 3
local DEFAULT_PROFILE = {
version = CURRENT_VERSION,
coins = 0,
inventory = {},
settings = { music = true },
}
local MIGRATIONS: { [number]: (any) -> any } = {
[1] = function(data) data.settings = { music = true } return data end,
[2] = function(data) data.inventory = data.items or {} data.items = nil return data end,
}
local function migrate(data: any): any
while data.version < CURRENT_VERSION do
local step = MIGRATIONS[data.version]
if not step then error(`missing migration from v{data.version}`) end
data = step(data)
data.version += 1
end
return data
end
migrate on load, inside the same UpdateAsync that claims the lock.DEFAULT_PROFILE for new players (a shared table reference will
corrupt across players).CFrame → 12 numbers or
position+orientation, Color3 → hex string, Vector3 → {x, y, z},
enum → enum.Value.nil holes in arrays before saving (JSON truncates at the
first hole).| Red flag | Why |
|---|---|
SetAsync for player data anywhere | Races; use UpdateAsync. |
| Saving inside gameplay events ("save on every coin pickup") | Throttled key writes; autosave instead. |
game:BindToClose missing | Server shutdown wipes the last minutes of every session. |
| Data loaded without session lock, "we'll be fine" | Item dupes, discovered by players before you. |
| Storing the whole leaderstats folder / Instances | Not serializable; save plain tables and rebuild UI. |
| One giant DataStore key for all players | Size limit + write throttling + total loss blast radius. |
| Trusting client-sent data into the profile | See the roblox-security skill: validate first. |
Wiping nil results as "new player" without checking the error | A failed GetAsync/UpdateAsync read looks like a new player if you don't distinguish "no data" from "call failed". Kick on load failure rather than starting a fresh profile over live data. |
That last one deserves emphasis: if the load fails, do not let the player play with a default profile — their next save overwrites the real data. Kick with a "data couldn't load, please rejoin" message.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
roblox, datastore, player-data, session-locking, data-persistence
npx claudepluginhub ivar-anon/roblox-dev --plugin roblox-dev10 skills in this plugin
/luau-strict-typingLuau strict mode typing patterns — annotations, narrowing Instance? results, forward declarations, typed remotes, generics, and fixing common --!strict type errors. Use when writing Luau code, enabling --!strict, or resolving Luau type-checker warnings in Roblox projects./new-systemGenerate a complete, secure client/server gameplay system for Roblox — shared types, validated server module, client controller, and remote registration in one pass. Use when adding a feature like a shop, inventory, combat ability, quest, or any system that spans client and server./reviewRun a structured security, data-safety, performance and typing review of Roblox/Luau code using the roblox-reviewer agent. Use when asked to review Roblox code, audit a game for exploits or leaks, or before shipping a system.Other plugins' skills for the same job