Store
Type
Store reads and writes per-key values in a local server save file opened with Store.Open; see Store for file paths. Keys are strings of 1 to 128 bytes, up to 4,096 unique keys per store. Every method returns a StoreStatus first.
Get
Method
Get(key: string) -> (StoreStatus, StoreValue?)
Get reads key from memory and returns (status, value). When key has no entry, Get returns "Ok", nil.
Example
-- Server script.
local saves = Store.Open("player_gold")
saves:Set("1001", { gold = 50 })
local status, data = saves:Get("1001")
if status == "Ok" and type(data) == "table" then
print((data :: { gold: number }).gold)
end
Set
Method
Set(key: string, value: StoreValue) -> StoreStatus
Set writes value under key and returns a StoreStatus. A value is a finite number, boolean, string, finite Vector3, buffer, or nested table (up to 8 levels and 65,536 encoded bytes). Passing nan or infinity raises an error.
Example
-- Server script.
local saves = Store.Open("player_gold")
local status = saves:Set("1001", { gold = 120, home = Vector3.new(0, 5, 0) })
if status == "Ok" then
local _, saved = saves:Get("1001")
if type(saved) == "table" then
print((saved :: { gold: number }).gold)
end
end
Remove
Method
Remove(key: string) -> (StoreStatus, boolean?)
Remove deletes key from the store and returns (status, removed).
Example
-- Server script.
local saves = Store.Open("player_gold")
local status, removed = saves:Remove("1001")
print(status, removed)