Simple Datastore system using Profileservice

Datastore.rbxm (32.0 KB)

I see people have trouble with Datastores almost all the time, so here’s like a very simple use case of profileservice, just throw the module and the script into ServerScriptService.

There’s a child of the script which is a folder called “info”. This holds all your values like boolvalues, integervalues, numbervalues, stringvalues, etc… any time you want to add a new value just place one into the folder, name it, and set the value to anything you want the default to be.

Example,
I placed a numbervalue inside the folder and called it “gold”, then I set the gold’s value to 100. And when a player joins the default gold they start with is 100.

The info folder gets cloned to the player, so to change data you just have to change a value and it will automatically save when you leave

Example,
Player.Info.Gold.Value += 50

^ That right there will save and you dont have to do anything else.

The code is good at just being simple and straightforward as possible, add values to folder to make data, and then those values will save when you leave.

1 Like

I’ve used this system for a while and really appreciate the simplicity, learning about datastores was overwhelming and took me wayyy too much time to even get close to figuring out. This allowed me to get on with actual development instead of going back and forth between forums so thank you.

I do have a question however, is there a way or any addition that needs to be done in order to delete a value? I’ve got a few values I am wanting to remove and whenever I do so it tends to break the system that assigns values and I’m worried it will cause data loss.

I haven’t used the datastore since I made it but it sounds like I forgot to put in a if statement to check when its setting the values data, if there is an actual value to set. This shouldn’t cause any data-loss but can be quite annoying to look at everytime the player joins.

Then there’s the fact that deleted values don’t delete themselves from the datastore like they should.

The best way to implement this is when the datastore is trying to set the player’s data to the values, if the value no longer exist than we’d skip over that data and set that data to nil.

Overall, since the system is so simple it also means its less flexible when it comes to these things. There’s many improvements that could be made and maybe I’ll get to it one day but I’d recommend if you`re planning on making medium/big projects to figure out the ins/outs of profileservice.

Profileservice is actually pretty simple to use and is very similar to roblox’s normal datastores.

Here’s an alright tutorial, if you want to take it on or you could implement the fix I stated above and it’ll probably be fine.

1 Like

I’ll have a crack at throwing in an IF statement when it is assigning variables to check if the value exists or not.

Thanks a bunch