Open Asterune
StorageService

StorageService

Server-side access to host-provided named stores.

Service
game:GetService("StorageService")
Inherits
Instance
Replication
Never

Behavior

StorageService opens named stores for the current place. Storage access is server-only. A store is identified by a name and an optional scope; use the returned Store value for reads and writes.

Durability depends on the host's storage provider. Standalone local games use the file provider when localStorage is enabled and an application directory is available. The standalone dedicated server keeps its store records in session memory; those records do not survive a process restart. An embedding host can supply a different provider. See application settings for local storage availability.

Store names and scopes are limited to 50 characters. Keys must be non-empty and shorter than 50 characters. Stored values can contain strings, numbers, booleans, and tables composed of those values, up to 64 KiB when encoded.

Summary

Members11
Properties3
  • Archivable: boolean = trueparallel readoverrides Instance

    Whether the service instance is included when its containing hierarchy is cloned or saved.

  • Name: string = "StorageService"parallel readoverrides Instance

    The instance name.

  • Parent: Instance? = nilparallel readoverrides Instance

    The service's parent instance.

Methods8

Properties

Archivable

StorageService.Archivable: boolean = true

Whether the service instance is included when its containing hierarchy is cloned or saved. The default is true.

Name

StorageService.Name: string = "StorageService"

The instance name. The default is "StorageService".

Parent

StorageService.Parent: Instance? = nil

The service's parent instance. The default is nil.

Methods

AddComponent

StorageService:AddComponent(component: Component | string, values: { [string]: any }?): ComponentHandle

Adds the named component and returns its ComponentHandle. Omitted fields use schema defaults. Initial values are validated before they are applied. Required components are added with it. Adding a component requires serial execution.

GetComponent

StorageService:GetComponent(component: Component | string): ComponentHandle?

Returns a ComponentHandle when the instance has the component, or nil when it does not.

GetComponentChangedSignal

StorageService:GetComponentChangedSignal(component: Component | string, field: string?): AstScriptSignal<string>

Returns the signal for changes to this instance's component. Supply a field name to observe that field. Without a field, the signal reports the changed field's name.

GetExecutionGroup

StorageService:GetExecutionGroup(): ExecutionGroup?

Returns this instance if it is an ExecutionGroup. Otherwise returns the nearest ancestor ExecutionGroup, or nil when no group contains the instance.

GetReferencing

StorageService:GetReferencing(component: Component | string, field: string?): { Instance }

Returns Instances whose reference fields point to this instance. The component selects the schema; an optional field restricts the search to one reference field.

HasComponent

StorageService:HasComponent(component: Component | string): boolean

Returns whether the instance has the specified component. Accepts a Component definition or a component name.

Open

StorageService:Open(name: string, scope: string?): Store

Opens a named store and returns a Store. scope is optional and defaults to "global". The call is server-only and yields while the backing storage operation is prepared.

RemoveComponent

StorageService:RemoveComponent(component: Component | string): boolean

Removes the component and returns whether it was present. Fails if another attached component requires it. Removing a component requires serial execution.

Inherited members

Inherited38

Example

Luau
local StorageService = game:GetService("StorageService")
local scores = StorageService:Open("scores", "season-1")

scores:Set("player-42", { score = 120, wins = 3 })
local record = scores:Get("player-42")

Store · json · Script