Skip to content

K.Data ​

Functions ​

K.Data.Template ​

lua
K.Data.Template(values: { [string]: any })

Sets default values for every player's data. Missing fields are added to existing saves automatically, so you can add new fields any time.

K.Data.Migrate ​

lua
K.Data.Migrate(version: number, run: ({ [string]: any }, number) -> ())

Adds a migration that updates saves older than version (see the top of this file). Call it before K.Start(), in the order you like; they always run by number.

K.Data.Version ​

lua
K.Data.Version(): number

The highest migration number added with K.Data.Migrate (0 when there are none).

K.Data.Get ​

lua
K.Data.Get(player: Player): { [string]: any }

The player's data table. Change it directly; it saves automatically.

K.Data.IsLoaded ​

lua
K.Data.IsLoaded(player: Player): boolean

K.Data.Wait ​

lua
K.Data.Wait(player: Player, timeout: number?): { [string]: any }?

Waits until the player's data loads. Returns nil if they leave or it takes over timeout seconds.

K.Data.Save ​

lua
K.Data.Save(player: Player): boolean

Saves right now instead of waiting for the next auto-save. Yields; returns true on success.

K.Data.Erase ​

lua
K.Data.Erase(userId: number): boolean

Permanently deletes a user's saved data (for example for a data deletion request). Yields.

K.Data.Start ​

lua
K.Data.Start()

Starts loading and saving players, for games that use Data without the rest of Corode: require(ReplicatedStorage.Corode.Data). With Corode itself, call K.Start() instead, which starts Data too.

Events ​

K.Data.Loaded ​

Fires with (player, data) after a player's data has loaded.

Generated from src/Corode/Data.luau.

Corode 0.13.0 · MIT License