PlayerData Module
In your wally.toml file, add this to your dependencies:
You have two solutions to import this module, depending if you wish to import the Controller or the Service on your own, or if you let the module give you the right code.
Configuration
A file called DataModule.config.lua is to be created in ReplicatedStorage/Shared/Configs.
Explanation:
ProfilesTemplate: A template for the ProfileService, it serves as a config for data saving.
Infos: Holds different information regarding the data store:
Key: The identifier to store data
Versions: Current version of the data key (can be used, as example, to wipe data).
UseDefaultKey: Allows to use the proper game key even in the studio.
AutoLoad: A boolean that, if set to true, allows the module to handle by itself data save and load. Set it to false if you want to use your own data system.
BindToCloseDisabledInStudio: A boolean allowing the game to save data in studio when it’s about to shut down completely.
Usage
This module provides functions to handle data saving, loading, and editing quite easily.
Events
OnDataLoaded: Triggers when the player's data is loaded.
OnDataUpdated: Triggers when the player's data is updated.
Methods (Server Only)
This method is used to load the player's data whenever they join.
Usage
Explanation
player: The player to load the data of.
This method is used to save the player's data.
Usage
Explanation
player: The player to save the data of.
These methods are used to free the player's data safely.
Usage
Explanation
player: The player to free the data of.
Explanation
callback: The callback to be called whenever PlayerRemoving is fired.
Usage
Explanation
player : The player to load the data for.
If needed, you can fetch specific data from the player's store
Explanation
player: the player you attempt to fetch / set data of
key: the key of the data you're wishing to fetch / set
value: the value of the data you're wishing to set