roblox-datastores
БесплатноБез исполняемых скриптовНе проверенRoblox DataStoreService persistence: load on join, save on leave and BindToClose, UpdateAsync vs SetAsync, session locking and OrderedDataStore leaderboards…
от gamedev-skills★ 12 656 звёзд на GitHubОб этом скилле
Roblox DataStores
Persist data across sessions without losing or duplicating it. All DataStore calls are network
requests from server Scripts; they can fail, be throttled, and race with another server writing
the same key.
Workflow
- Find the existing persistence layer. Search for
DataStoreService,GetDataStore, and any profile or session library before writing new code. If the project already uses one, extend it; two systems writing the same key is the most common cause of rollbacks. - Use a test place for Studio work. Studio reads and writes the same live data as players.
In a separate published test place, turn on File → Experience Settings → Security → Enable
Studio Access to API Services; without it, requests fail with
StudioAccessToApisNotAllowed. - Key by
UserId, never by name:"Player_" .. player.UserId. - Guard every call with
pcall. On a failed load, mark the session as not loaded and refuse to save, so defaults never overwrite real data. - Load on
PlayerAdded, save onPlayerRemovingand ingame:BindToClose, plus a periodic save (every 60-120 s), never on every value change. - Write with
UpdateAsyncand session ownership.UpdateAsyncreads the latest value before writing; session ownership (inreferences/sessions-and-limits.md) stops a stale server from writing an old snapshot over newer progress. - Use
OrderedDataStoreonly for numeric rankings (leaderboards). - Check before reporting. Run the static check below and fix every hit. Then, with the Studio
MCP server connected, API access on in a test place, and the user's MCP Permissions → Save &
load data scopes enabled for that game (
universe-datastores.objects:read, plus:updatefor writes; the agent cannot turn these on), play, change a value, stop, play again, and read it back with an uncached read fromexecute_luauon theServerdatamodel. A502 … Access forbiddenerror means the scope is off. Without MCP, ask the user to do join, change, leave, rejoin in the test place and report the value seen after rejoining and any Output warnings. Rate-limit behavior needs Team Create, not Run mode.
# Every DataStore call should sit inside pcall; this lists the lines to inspect by hand.
rg -n ":(GetAsync|SetAsync|UpdateAsync|IncrementAsync|RemoveAsync|GetSortedAsync)\(" src
rg -n "BindToClose" src # expect at least one save-everyone handler
rg -n ":SetAsync\(" src # each one on a player profile key needs a reason
Patterns
Load on join
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local store = DataStoreService:GetDataStore("PlayerData")
local DEFAULT = { Coins = 0, Level = 1 }
Players.PlayerAdded:Connect(function(player)
local key = "Player_" .. player.UserId
local ok, data = pcall(function()
return store:GetAsync(key)
end)
if not ok then
warn("Load failed for", player.UserId, data) -- network failure, not a new player
player:SetAttribute("DataLoaded", false)
return
end
player:SetAttribute("DataLoaded", true)
applyToLeaderstats(player, data or table.clone(DEFAULT)) -- nil means a genuinely new player
end)
Save with UpdateAsync (session ownership still required)
This callback ignores old, so on its own it can overwrite newer progress from another server.
Before shipping, add the session check from references/sessions-and-limits.md inside the
callback, or use a vetted profile library.
local function savePlayer(player)
-- `~= true` also covers a player who left while GetAsync was still in flight.
if player:GetAttribute("DataLoaded") ~= true then return end
local key = "Player_" .. player.UserId
local newData = gatherDataFor(player) -- plain, JSON-serializable table
local ok, err = pcall(function()
store:UpdateAsync(key, function(old)
-- Must not yield and may run more than once. Return nil to cancel the write
-- when this session no longer owns the key.
return newData
end)
end)
if not ok then warn("Save failed for", player.UserId, err) end
end
Save on leave and on shutdown
Players.PlayerRemoving:Connect(savePlayer)
game:BindToClose(function()
local players = Players:GetPlayers()
local remaining = #players
for _, player in players do
task.spawn(function()
savePlayer(player)
remaining -= 1
end)
end
while remaining > 0 do task.wait() end -- the server waits at most 30 s in total
end)
Retry only what is safe to repeat
local function withRetry(fn, attempts)
attempts = attempts or 3
for i = 1, attempts do
local ok, result = pcall(fn)
if ok then return true, result end
if i < attempts then task.wait(2 ^ i + math.random()) end -- jitter
Установить roblox-datastores в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл roblox-datastores?
Roblox DataStoreService persistence: load on join, save on leave and BindToClose, UpdateAsync vs SetAsync, session locking and OrderedDataStore leaderboards. Use for lost player data, items duplicating after teleport, or "too many requests" errors. Not for engine-neutral saves (`save-systems`), Luau basics (`roblox-luau`) or economy numbers (`roblox-simulator-economy`).
Как установить скилл roblox-datastores?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл roblox-datastores запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic