i made this module so I could easily swap out legacy DataPersistence calls that no longer function then i realized this module would probably be a good standalone datastore module
API docs
dat:IsReady(p : Player)
- Returns whether a player’s data is loaded and can be saved
dat:RegisterJoinFunction(name,func)
- Registers a function that runs after a player’s data has been loaded
Depending on the situation you should either use this or wait for dat:IsLoaded() to return true
functions should be structured like so:
dat:RegisterJoinFunction("test",function(p: Player, plrdat) --info about plrdat is below
print(plrdat:LoadValue("super secret string"))
end)
dat:RemoveJoinFunction(name)
- Removes a join function
dat:GetFunctions(p : Player)
- Returns the player interface
the player interface has all of the old data persistence functions (excluding LoadInstance and SaveInstance) along with LoadValue and SaveValue
LoadValue and SaveValue are recommended but all of them function identically and don’t even have type checking
The interface has the following functions
plrdat:SaveNumber(key,value)
plrdat:LoadNumber(key)
plrdat:SaveString(key,value)
plrdat:LoadString(key)
plrdat:SaveBoolean(key,value)
plrdat:LoadBoolean(key)
plrdat:SaveValue(key,value)
plrdat:LoadValue(key)
The following functions are used in DataPersistenceLoader
dat:LoadPlayer(p : Player)
dat:RemovePlayer(p : Player)
it is recommended you just use the bundled script as it handles joining, leaving, and the server shutting down for you
To install
Insert the model, remove the scripts from the folder, and place them both in ServerScriptService
Make sure to enabled studio access to API services!
Note: i can’t get data to save in studio, only load which I am pretty sure is a roblox bug
both data saving and loading works ingame!
leave any feedback in the comments