Scripting:Data Persistence

About

Data persistence was added to Finobe on April 1, 2018. It is used to save and load user data from games.

Use Cases

  • Tycoon money
  • RPG statistics
  • Obby checkpoints
  • Building game builds (instances)

Usage

All data persistence methods are methods of the Player class. You must not call these methods from a LocalScript. They must only be called by the server.

Player:WaitForDataReady()

WaitForDataReady() yields until the data for the Player is ready. Note that this is a blocking method.

Example usage:

1 game.Players.Raymonf:WaitForDataReady()

Saving Data

Player:SaveBoolean(key, value)

Saves a boolean saved to the key passed in.

Example usage:

1 game.Players.Raymonf:SaveBoolean("isadmin", false)

Player:SaveInstance(key, value)

Loads an instance saved to the key passed in. An instance can be any object in a Finobe world, like a Model or a Part.

Example usage:

1 game.Players.Raymonf:SaveInstance("build", game.Workspace.Builds[game.Players.Raymonf.userId])

Player:SaveNumber(key, value)

Loads a number saved to the key passed in. Integers and decimals are supported.

Example usage:

1 game.Players.Raymonf:SaveNumber("score", 529)

Player:SaveString(key, value)

Loads a string saved to the key passed in.

1 game.Players.Raymonf:SaveString("fox", "The quick brown fox jumps over the lazy dog")

Loading Data

Player:LoadBoolean(key)

Loads a boolean saved to the key passed in.

Example usage:

1 local bool = game.Players.Raymonf:LoadBoolean("isadmin")
2 print(bool) -- false

Player:LoadInstance(key)

Loads an instance saved to the key passed in. An instance can be any object in a Finobe world, like a Model or a Part.

Example usage:

1 local object = game.Players.Raymonf:LoadInstance("build")
2 object.Parent = game.Workspace.Builds

Player:LoadNumber(key)

Loads a number saved to the key passed in. Integers and decimals are supported.

Example usage:

1 local num = game.Players.Raymonf:LoadNumber("score")
2 print(num) -- 529

Player:LoadString(key)

Loads a string saved to the key passed in.

1 local str = game.Players.Raymonf:LoadString("fox")
2 print(str) -- The quick brown fox jumps over the lazy dog