Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Saving leaderstats/playerstats between sessions?

Asked by 6 years ago

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?

0
Please note that you cant save in Studio. You'll need to test it in a server Paintertable 171 — 6y
0
You can save in studio. You have to give studio access to API services though. DinozCreates 1070 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

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. SummerEquinox 643 — 6y
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. DinozCreates 1070 — 6y
0
There is no need for a JSON resource outside of the documentation. It explains it fairly well iirc. SummerEquinox 643 — 6y
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. JakesRevenge 6 — 6y
0
I just noticed your question! Im sure you have the answer by now but you would use --- player.playerstats["Fire Crystal"].Value DinozCreates 1070 — 5y
Ad

Answer this question