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

How can I use DataStore to save values inside a folder?

Asked by 5 years ago

I have a folder in a player's leaderstats thats holds all of the players data. I want to save all the values inside that folder. How can i do that?

1 answer

Log in to vote
1
Answered by
LuaDLL 253 Moderation Voter
5 years ago

You would setup a normal data store and then check the folder and add the values to a table like this when a player leaves

1local UniqueKey = "Special-"..Player.UserId -- the key to the data store to get a certain players data
2local DataFolder = Player.leaderstats
3local Datatable = { -- Add values to this as needed
4    DataFolder.Level.Value,
5    DataFolder.Kills.Value,
6}
7Datastore:SetAsync(UniqueKey,Datatable) -- Saves All The Data
Ad

Answer this question