Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Saving leaderstats/playerstats between sessions?

I've seen a lot of scripts that are supposed to do this, but none of them seem to work correctly. I've tried to make my own, but it didn't work correctly either (and I've since deleted the script, so I can't post it here either).

Basically, if I'm in studio, and I test the game, I click on the "Players" tab and then I click on myself, and I see 7 folders. I want to save 2 of them in particular: leaderstats and playerstats. The leaderstats folder contains 3 StringValues, for money, blocks mined, and depth. The playerstats folder contains a lot of NumberValues, one for each ore in my game.

It would also help if I could save the players' backpacks between sessions. This is another one of the folders, and it just contains a pickaxe, but eventually players will be able to upgrade their pickaxes, and I want the upgrades to save.

Is there any actual way to do this?

2 comments

0

Please note that you cant save in Studio. You'll need to test it in a server

0

You can save in studio. You have to give studio access to API services though.

1 answer

✓ Accepted answer

https://scriptinghelpers.org/guides/saving-and-loading-data-with-datastores

This guide does a better job of explaining than I’ll ever be able to. As far as players backpacks the way I do this is that whenever they purchase an item I have a bool value and I turn it from ‘false’ to ‘true’, if true the item will be added to the players backpack and startergear when they load back in. You could even use this method for upgrading, you’d just turn the previous tool to false and the next one to true. You WILL need remote events for doing this. I don’t know how much you know about datastores(if anything) or remote events so if you have any specific questions feel free to ask.

5 comments

0

That is a good starter guide to DataStore. It's worth noting that it doesn't teach JSON at all, which is very useful for the items he says he is nesting.

0

If he can get items saving then at least we’ll be in the right direction! Let me see if I can find a resource for this.

0

There is no need for a JSON resource outside of the documentation. It explains it fairly well iirc.

0

Thanks, this helped a ton! However I still have a tiny problem. I'm trying to save ore values, but some of the ore names have spaces in them (ex. "Fire Crystal"). I've tried writing that as Fire_Crystal in this line of code: FireCrystal = player.playerstats.Fire_Crystal.Value, just wanted to know if that's how you write names with spaces.

0

I just noticed your question! Im sure you have the answer by now but you would use --- player.playerstats["Fire Crystal"].Value

This discussion is preserved as it was. New answers, comments, and votes are closed.