Roblox Server & Shared Data
When to Load
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; for Open Cloud and external APIs, use roblox-cloud.
Quick Reference
OrderedDataStore (Leaderboards)
- Sortable DataStore. Keys are strings; use a stable key such as
tostring(UserId).
- Values are integers used for sorting; choose the sign and ordering intentionally.
GetSortedAsync(ascending, pageSize, minValue, maxValue) → sorted pages
- For leaderboards only, not player data
local D = game:GetService("DataStoreService")
local store = D:GetOrderedDataStore("LeaderboardCoins")
store:SetAsync(tostring(player.UserId), playerCoins)
local top10 = store:GetSortedAsync(false, 10):GetCurrentPage()
MessagingService (Cross-Server)
- Real-time server communication:
SubscribeAsync / PublishAsync
- No delivery or ordering guarantee; design for idempotency.
GlobalDataStore (Shared State)
- Persistent non-player state such as guilds, seasons, and counters.
- Use
UpdateAsync; never use it for player session data.
MemoryStoreService (Temporary Coordination)
- Queues and sorted maps for expiring matchmaking, leases, and coordination.
- Remove a read batch only after successful, idempotent processing.
- Use MessagingService or TeleportData for notification and handoff.
Cross-Server Patterns
- Register servers with expiring heartbeats; use MessagingService for notifications.
Pitfalls
- MessagingService is fire-and-forget: no delivery guarantee, no ordering
- GlobalDataStore has same rate limits as player DataStores; don't spam
- OrderedDataStore keys are strings; values are integers used for sorting
- Never store Instances; serialize to primitives first
- UpdateAsync for any shared counter to prevent lost updates
Need more detail? Load references/full.md for the complete reference with code examples, API tables, and edge cases.
1---2name: roblox-server-data3description: "Use for Roblox server or cross-server data: OrderedDataStore leaderboards, MessagingService, world state, seasons, or guilds."4last_reviewed: 2026-08-215sources:6 - https://create.roblox.com/docs/reference/engine/classes/OrderedDataStore7 - https://create.roblox.com/docs/reference/engine/classes/MessagingService8 - https://create.roblox.com/docs/reference/engine/classes/GlobalDataStore9 - https://create.roblox.com/docs/reference/engine/classes/MemoryStoreService10 - https://create.roblox.com/docs/reference/engine/classes/MemoryStoreQueue11 - https://devforum.roblox.com/t/partyservice-plus-party-matchmaking-framework/466888312---1314# Roblox Server & Shared Data1516## When to Load1718Load 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`; for Open Cloud and external APIs, use `roblox-cloud`.1920## Quick Reference2122### OrderedDataStore (Leaderboards)23- Sortable DataStore. Keys are strings; use a stable key such as `tostring(UserId)`.24- Values are integers used for sorting; choose the sign and ordering intentionally.25- `GetSortedAsync(ascending, pageSize, minValue, maxValue)` → sorted pages26- For leaderboards only, not player data2728```luau29local D = game:GetService("DataStoreService")30local store = D:GetOrderedDataStore("LeaderboardCoins")31store:SetAsync(tostring(player.UserId), playerCoins)32local top10 = store:GetSortedAsync(false, 10):GetCurrentPage()33```3435### MessagingService (Cross-Server)36- Real-time server communication: `SubscribeAsync` / `PublishAsync`37- No delivery or ordering guarantee; design for idempotency.3839### GlobalDataStore (Shared State)40- Persistent non-player state such as guilds, seasons, and counters.41- Use `UpdateAsync`; never use it for player session data.4243### MemoryStoreService (Temporary Coordination)44- Queues and sorted maps for expiring matchmaking, leases, and coordination.45- Remove a read batch only after successful, idempotent processing.46- Use MessagingService or TeleportData for notification and handoff.4748### Cross-Server Patterns49- Register servers with expiring heartbeats; use MessagingService for notifications.5051### Pitfalls52- MessagingService is fire-and-forget: no delivery guarantee, no ordering53- GlobalDataStore has same rate limits as player DataStores; don't spam54- OrderedDataStore keys are strings; values are integers used for sorting55- Never store Instances; serialize to primitives first56- UpdateAsync for any shared counter to prevent lost updates5758**Need more detail?** Load `references/full.md` for the complete reference with code examples, API tables, and edge cases.