I’m not really familiar with the concept, and a lot of the old methods I used in the past are depreciated/don’t work anymore.
How would I go about this?
I’m not really familiar with the concept, and a lot of the old methods I used in the past are depreciated/don’t work anymore.
How would I go about this?
The scripting support category is for help on your scripts. Not asking people to write whole scripts for you. You can look up a tutorial. Or hire someone to do this.
While I would advise you to look into Datastore2, you can also look into Datastores by searching other posts on this topic or looking at the wiki.
Alvin Blox explains the concept of Data Stores really well. https://www.youtube.com/watch?v=DkYupSBUpes
To add on to that, Alvin Blox also has a tutorial on DataStore2 in case you decide to use that (Which I recommend) https://www.youtube.com/watch?v=hBfMfB0BwGA
Well, it’s as simple as using one of the DataStore methods in PlayerAdded or PlayerRemoving depending on your case. What matters is other implementation details you might want to have in your data system.
There are many code samples around the DevForum and the Developer Hub, so the first thing you should be doing is familiarising yourself with the API. Believe me, I didn’t understand how DataStores worked either but a quick skim of the API made it easier than it appears. You’re basically just using a service to read from and write to tables.
Make either developer website the first stop, not a thread here on the DevForum.
Take a bit to understand it. If you don’t, backpedal a bit - you may lack knowledge on Lua itself and that’s dropping you off on trying to make sense of what DataStores are and how you can get the best use out of them.
On your thread, by the way, you mentioned that you used older methods and they are now deprecated or unworking. Do you mind sharing the exact implementation or the implementation concept behind your previous methods and why they are supposedly antiquated now?
Usually, I use a method of saving a dictionary (if you’re unfamiliar with these then you should go learn them) with the indexes set as the Name of the leaderstat along with the value being the Value of the leaderstat.
Obviously, you can iterate through GetChildren of the leaderstats to achieve this fast than having to write each and every one individually.
Once you receive the data when they join again of course you can directly index the name, simples.
Now, for example creating the dictionary to save would look similar to:
local dictionary = {}
for _, leaderstat in ipairs(player.leaderstats:GetChildren()) do
dictionary[leaderstat.Name] = leaderstat.Value
end