Skip to content

CloudStore

System · CloudStore · server and client scripts

CloudStore saves player data in the cloud, where every server of the place can read it. Use Store when the data stays on one server machine.

Methods on a CloudStore or SortedCloudStore handle yield until the request completes and return a StoreStatus first. Each server has these limits:

  • Reads and writes each have a budget of 60 requests a minute plus 10 for each player in the place. Update spends one read and one write, plus more on each version-conflict retry.
  • At most 30 requests can wait for the cloud backend at once.
  • A value is at most 262144 bytes; a larger value returns "TooLarge" without sending a request.
  • A key has 1 to 128 bytes and no control characters.
  • A store name has 1 to 50 letters, digits, '_', or '-', and a place opens at most 16 stores.

Open

FunctionServer only
Open(name: string) -> CloudStore

Open opens the key-value store name and returns its CloudStore handle. Opening the same name again returns the same store.

Example

-- Server script.
local profiles = CloudStore.Open("player_profiles")

Component.User.Added:Connect(function(player: Entity)
    local user = player.User
    if not user then
        return
    end
    local status = profiles:Set(tostring(user.Id), { gold = 100 })
    if status ~= "Ok" then
        warn(status)
    end
end)
Errors (1)
Error When
Open can only be called from the server Called from a client script.

OpenSorted

FunctionServer only
OpenSorted(name: string) -> SortedCloudStore

OpenSorted opens the leaderboard store name and returns its SortedCloudStore handle. A sorted store maps each key to a whole-number score and reads keys sorted by score; opening the same name again returns the same store.

Effects

  • Set returns "KeyLimit" when the store already has 4,096 keys and "QuotaFull" when the place's storage quota is full.
  • A local test server keeps scores in memory, so they are gone when it stops.

Example

-- Server script.
local highScores = CloudStore.OpenSorted("weekly_high_scores")

Component.User.Added:Connect(function(player: Entity)
    local user = player.User
    if not user then
        return
    end
    local status = highScores:Set(tostring(user.Id), 0)
    if status ~= "Ok" then
        warn(status)
    end
end)
Errors (1)
Error When
OpenSorted can only be called from the server Called from a client script.