Roblox Data

TabooHarmony/roblox-brain/skills/core/roblox-data

作者 TabooHarmony38826be57ee37bcf023e9c2b85681bea3909281c无许可证收录于 2026年10月9日更新于 2026年10月9日

Use when implementing player data persistence with DataStore, session ownership, schemas, migrations, or save and load flows.

AI 生成的概览

指导 Roblox 玩家数据持久化,涵盖 DataStore、会话归属、模式、迁移以及保存与加载流程。

功能
该技能为在 Roblox 体验中实现玩家数据持久化提供参考指导。内容涵盖定义带版本字段的可序列化模板、使用 UpdateAsync 进行读取-修改-写入、防止并发会话同时修改、在生命周期边界保存、校验存储值,以及处理被遗忘权(RTBF)的键方案。它还指向一份更完整的持久化工作流参考文档。
适用场景
适用于实现或审查 Roblox 玩家保存与加载系统、数据模式、迁移、重试、关闭处理或会话归属的场景。它面向基于 DataStore 的持久化,而非排行榜、消息、世界数据或 Open Cloud。
运行要求
无脚本,仅为说明性内容。它假定处于具备 DataStore 访问权限的 Roblox 开发环境,并引用一份额外的模型可读参考文件。

roblox data persistence

When to Load

Load for player saves, migrations, retries, shutdowns, or session ownership. Leaderboards/messaging/world data: roblox-server-data; Open Cloud: roblox-cloud.

Quick Reference

  • Define a serializable template and a version field before storing player state. Deep-copy templates so nested defaults are not shared; migrate, then reconcile missing fields against the template. Scope store names by environment (PlayerData_Studio) so Studio writes stay out of production.
  • Use UpdateAsync for read-modify-write; handle throttling and transient errors.
  • Prevent two servers mutating one profile at once: a session-ownership wrapper or equivalent protocol.
  • With ProfileStore: StartSessionAsync, Profile.OnSessionEnd, EndSession as documented; no Steal for normal loads; ProfileStore.Mock for ephemeral Studio writes.
  • Save on meaningful changes and lifecycle boundaries; PlayerRemoving alone is not sufficient. BindToClose finishes pending work.
  • Store primitives, arrays, dictionaries; convert Instances/userdata/functions/cyclic tables first. Validate numbers (no NaN/inf), strings (utf8.len), nested tables: one bad value fails the write.
  • RTBF: keep the user ID as a static substring in keys (player_<UserId>) so {UserId} deletion templates can match; hashed or random keys make erasure manual.
  • GetAsync serves a 4-second local cache (DataStoreGetOptions.UseCache, default true); verify writes with UseCache = false.
  • Poll DataStoreService:GetRequestBudgetForRequestType for live headroom; quotas scale with concurrent users (experience reads: 300 + concurrentUsers x 40/min).
  • New code identifies users with player.User (User.Id, DomainType, DomainId); UserId remains valid, but never mix the two IDs in one key scheme.

Persistence workflows: references/full.md [blocked]

来源与署名

来源:TabooHarmony/roblox-brain位于skills/core/roblox-data提交38826be

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架