BetterDataStores Model

OUTDATED:

What is BetterDataStores?

BetterDataStores is my latest open-sourced model for any developer to be able to use to allow for easy and impressive data saving without require programming! Using this model, you can simply add a value and the game will already understand what to do.

Get the model here: https://create.roblox.com/store/asset/91438623590909/BetterDataStores-V1
Play the demo showcasing this here (UNCOPYLOCKED): EasyDataStores Demo - Roblox


How to use:

First Opening: When you first open the model you will see a tutorial script which will also allow for reparenting everything required encase you forget or don’t want to. If you do want to then you simply put the DataStores script in ServerScriptService. Then in the DataStores script you will notice a few folders…

What’s PublicPlayerData? PublicPlayerData is just another name for values that can be viewed in leaderstats. You can simply add values here and when you play the game, it will appear and save the contents of the values. (PublicPlayerData can ONLY contain values. Attempting to put anything else will return warnings and not appear)

Remember that when dealing with DataStores, you must update values though a server script. The refrence for a value in PublicPlayerData is shown below

(PlayerName/LocalPlayer).leaderstats.(ValueName).Value

What’s HiddenPlayerData? HiddenPlayerData is sets of either veriables or folders/tables of data this is not visible in the leaderstats. This means that this is good for saving internal player data like what they have equipped or whatever you need it for. (HiddenPlayerData can have both values and folders to save data but if it is not a value or folder then warnings will return, More infomation on saving folders further down)

Remember that when dealing with DataStores, you must update values though a server script. The refrence for a value in HiddenPlayerData is shown below

(PlayerName/LocalPlayer).(ValueName).Value

How do I set a default value? You can simply do this by adjusting the value of the data you want to have a custom default value for. Couldn’t be simpler :slight_smile:

[NEW] Folder/Table Saving:
:warning:This part is a little more advanced and currently considered to be a BETA feature meaning that some things are expected to not work as I continue to improve this section. Please give me feedback below as I continue to work on this! (Currently, this feature is functional)

Before learning about how to do this, Please remember the following:

  • This feature is in BETA with some things not currently set up to work, Please keep on the lookout for updates revolving this!
  • Folder/Table Saving is ONLY available for HiddenPlayerData to prevent unexpected behaviour.
  • Using this is a lot more advanced and tricky for me to programme due to Roblox Lua not supporting code that I need it to support
  • When you’re adding or removing instances for a Folder/Table save, You must do it via a Server Script.
  • Folders cannot be named ‘leaderstats’, ‘StarterGear’, ‘PlayerGui’, ‘PlayerScripts’ or ‘Backpack’ to avoid the script getting confused.

Using this feature, you can easily create systems such as an inventory. To do this, simply add a folder to HiddenPlayerData and via server scripts you can add and remove instances so that when a player leaves and rejoins… Its there! You’ll even notice that anything parented to that instance will also save with it

Limitations: While any instance is eligible to be saved though this way, Please note that currently only specific built-in properties will save. These are Position, Size, Color, Text, Image, TextColor3, Transparency and Value. This has been done due to Lua complications in easily retrieving all properties.

Workarounds to limitations: As a work around while I continue to update this feature, You can use attributes which will all also be saved and from there you can use that infomation as you like including to set built-in properties. Once again sorry that this part is a little more complex.


Whats to come with this?

  • Improvements to Folder/Table saving including more saveable priorities and reducing issues where needed
  • Constently looking for feedback to implement. You can submit feedback here!
  • More customisable settings to have better control over savings including saving player Backpack directly from a setting

Hopefully you enjoy using this model for your own projects. I wanted to create something that would benefit developers of all types from beginners to more advanced and hopefully you can easily benifit from this. Please report any problems and feedback below.

Get the model here: https://create.roblox.com/store/asset/91438623590909/BetterDataStores-V1
Play the demo showcasing this here (UNCOPYLOCKED): EasyDataStores Demo - Roblox

Current Version: 2
Last Updated: 26th October 2024

3 Likes

Very cool idea! I think having DataStores be interfaced with instances makes them really intuitive to use, and is great for beginners and even experienced developers wanting to make projects quickly.

Could you perhaps give a code example of basic usage for get saved data?

It’s probably required to use WaitForChild at some point so that data that needs to be loaded from datastores can be retrieved, correct?

1 Like
	local leaderstats = player:FindFirstChild("leaderstats")
	if leaderstats then
		for _, v in ipairs(script.PublicPlayerData:GetChildren()) do
			local playerStat = leaderstats:FindFirstChild(v.Name)
			if playerStat and savedStats[v.Name] ~= nil then
				playerStat.Value = savedStats[v.Name] or v.Value
			end
		end
	end

What’s simply happening for getting saved data is that the script is one by one going though all the values in that folder and looking for it in the data store before finally setting the value unless it returns nil in which case the value is new or did not save correctly. I assume that’s what you asked

1 Like

I will be updating this model again either Monday or Tuesday. With this I’ll be introducing settings to allow for better customisations over data management for both player side and server side as well as allowing developers that use this model to have better contol over what properties should be saved and retrieved in Folder/Table savings.

Oh, okay, very interesting. I was thinking that the module created the folders. It might be cool to have an attribute added to the value instances after their value is loaded and set from the datastores.

Overall a very cool project! Setting the values instead of creating the instances makes it very easy to use!

This version is now outdated

Please refer to easydatastores continuing as the name is more fitting along side the new settings feature with stuff like Saving Backpack, custom table property saves, economy analytics and more!

NEW VERSION, CLICK HERE