$npx -y skills add TabooHarmony/roblox-brain --skill roblox-server-dataUse for Roblox server or cross-server data: OrderedDataStore leaderboards, MessagingService, world state, seasons, or guilds.
| 1 | # Roblox Server & Shared Data |
| 2 | |
| 3 | ## When to Load |
| 4 | |
| 5 | Load for server-level or cross-server data: leaderboards (OrderedDataStore), cross-server messaging (MessagingService), temporary queues and sorted maps (MemoryStoreService), shared world state, persistent non-player data, season/guild data. For player data (DataStore, ProfileStore, session locking), use `roblox-data`. |
| 6 | |
| 7 | ## Quick Reference |
| 8 | |
| 9 | ### OrderedDataStore (Leaderboards) |
| 10 | - Sortable DataStore. Keys are strings; use a stable key such as `tostring(UserId)`. |
| 11 | - Values are integers used for sorting; choose the sign and ordering intentionally. |
| 12 | - `GetSortedAsync(ascending, pageSize, minValue, maxValue)` → sorted pages |
| 13 | - For leaderboards ONLY — not player data |
| 14 | |
| 15 | ```luau |
| 16 | local D = game:GetService("DataStoreService") |
| 17 | local store = D:GetOrderedDataStore("LeaderboardCoins") |
| 18 | store:SetAsync(tostring(player.UserId), playerCoins) |
| 19 | local top10 = store:GetSortedAsync(false, 10):GetCurrentPage() |
| 20 | ``` |
| 21 | |
| 22 | ### MessagingService (Cross-Server) |
| 23 | - Real-time server communication: `SubscribeAsync` / `PublishAsync` |
| 24 | - No delivery or ordering guarantee; design for idempotency. |
| 25 | |
| 26 | ### GlobalDataStore (Shared State) |
| 27 | - Persistent non-player state such as guilds, seasons, and counters. |
| 28 | - Use `UpdateAsync`; never use it for player session data. |
| 29 | |
| 30 | ### MemoryStoreService (Temporary Coordination) |
| 31 | - Queues and sorted maps for expiring matchmaking, leases, and coordination. |
| 32 | - Remove a read batch only after successful, idempotent processing. |
| 33 | - Use MessagingService or TeleportData for notification and handoff. |
| 34 | |
| 35 | ### Persistent World State Patterns |
| 36 | - **Building games**: serialize player-built structures to DataStore and reload on join |
| 37 | - **Seasons/leaderboards**: OrderedDataStore for rankings, GlobalDataStore for metadata |
| 38 | - **Guilds**: GlobalDataStore by guild ID, MessagingService for live updates |
| 39 | - **Economy counters**: GlobalDataStore + `UpdateAsync` for atomic increments |
| 40 | |
| 41 | ### Cross-Server Patterns |
| 42 | - Register servers with expiring heartbeats; use MessagingService for notifications. |
| 43 | |
| 44 | ### Pitfalls |
| 45 | - MessagingService is fire-and-forget — no delivery guarantee, no ordering |
| 46 | - GlobalDataStore has same rate limits as player DataStores — don't spam |
| 47 | - OrderedDataStore keys are strings; values are integers used for sorting |
| 48 | - Never store Instances — serialize to primitives first |
| 49 | - UpdateAsync for any shared counter to prevent lost updates |
| 50 | |
| 51 | **Need more detail?** Load `references/full.md` for the complete reference with code examples, API tables, and edge cases. |