Storing player data?

I’m currently working on a game. I’ve always used folders and string values to hold my players data. For example like inventory data, etc. But for my new project i’m gonna have a big shop full of stuff to buy. I need to be able to save everything the player has bought. And be able to access the data. Whats the best way to do this? I’m guessing string values and folders are not the best way to go. Thanks for the help!

Well for getting the stuff in your shop I’d recommend a module script which holds the price, description, name etc of the products you want to sell to people or the products which your NPCs may want to buy.

As for the player data itself, it really depends on what it is and how you plan to reload your data. In one of my data stores we had minimal tools a player could buy however a player could buy variations / upgrades on the tool meaning I had store within a table a bunch of dictionaries so I could get the tool name and the relevant settings.

If your doing resources such as wood etc then if you know how many different resources you want to have (let’s say wood, iron, gold) then giving them independent values in a dictionary would do fine but if you want something more robust then either making an adaptable dictionary or storing them in a table is the next easiest way.

Your going to have to learn about the datastore service though as if you store things in folders and string values then a player will only have the stuff for a single server and it won’t be replicated across many servers. I do wish you luck with data storage as it can be a real task sometimes :joy:

2 Likes

Well the shop im working on is for weapons. Players can buy the weapon and then it equip it from the store gui. Only problem is how do I store all the data if the player has bought the item or not.

Using the datastore service:

Then as for if the player has purchased it then if all purchases are stored within a table you could search for a specific ID or the name of a product within the table > if it’s present then it’s most likely they have purchased this item before and as such you can make it so it treats it in a different manner to a purchase.

We don’t really want to have a non-robust solution as chances are a shop may have items added etc. If your products can be modified then you’ll have to store more data in said of a string in let’s say a table called purchases.

If you get really stuck with making a data store then message whenever. :slightly_smiling_face:

1 Like

I would use DataStore2 it is a more efficient data store when saving big stuff, and is actually easier then a regular data store, here is an article about it on dev forum:

1 Like