Datastore for simple game

Hello,

As the title suggests, I am trying to make a data store for my game. It’s a simple game being that it’s a small side project I’m working on for practice + some possible income, and I’m trying to figure out what would be the best way to make a datastore system that can manage dozens and dozens of values. It’ll be a game where you collect resources like wood and stone, and I want to simply be able to search for the players current Stone count, and either add or subtract and have it save upon them leaving.

It’ll also have a base building aspect which I’d also like to save the buildings which I imagine I could basically just have a folder in the workspace housing all the buildings, and upon leaving, that folder gets tossed into the player’s data and then pulled out when joined, but I’m new to datastore and don’t know much. I was hoping someone far more experienced than I could perhaps guide me in the right direction or share some knowledge with me. I attached an example of the many stats I am trying to save. I know it’s a lot.

I’m a solo developer so any and all help really does mean the world to me. It’s currently 4:26AM at the time of this writing and I need to get some rest. Thank you for your time and your patience.

1 Like

use ProfileService it is pretty good
https://madstudioroblox.github.io/ProfileService/

1 Like

One advice i have for games with lots of values is to make a data schema, which is where you define what values will be in your game. The schema should be sturctured as a tree (or hierarchy), where you can have folders inside of folders. This will make accessing the values easier than just using one folder with every value inside of it.

An example of how a schema could look is like:
-- ModuleScript Schema
return {
	{
		DataName = "MainStats", -- The name that that it will be stored in the data store
		DataType = "Folder",
		Children = {
			{
				DataName = "Money",
				DataType = "NumberValue",
				DefaultValue = 0,
			},
			{
				DataName = "Gems",
				DataType = "NumberValue",
				DefaultValue = 0,
			},
			{
				DataName = "Totals", 
				DataType = "Folder",
				Children = {
					{
						DataName = "TotalMoney",
						DataType = "NumberValue",
						DefaultValue = 0,
					},
					{
						DataName = "TotalGems",
						DataType = "NumberValue",
						DefaultValue = 0,
					},
				},
			}
		}
	},
	{
		DataName = "Buildings", 
		DataType = "Folder", 
		Children = {
			{
				DataName = "GoldMine",
				DataType = "Folder",
				Children = {
					{
						DataName = "IsUnlocked",
						DataType = "BoolValue",
						DefaultValue = false,
					},
				}
			},
		}
	},
}

Then there would be another script that creates the NumberValues, BoolValues, Folders and other Instances from the schema everytime each player joins and saves it.

Ultimately, creating a data store solution is really hard, and there’s so many things you have to consider. If you don’t think you’re up for it, but still want a good datastore solution, then using data store libraries like the aforementioned ProfileService will be the best choice for you.

2 Likes

Thank you to both of you, I’ll be looking into both of your replies and trying to work something out. Thank you.