How do you make multiple saves in a data store


I sound really dumb but uhh

How do you add multiple saves in a datastore (look at example) and create tables?
Its not an ordered datastore

local folder ="Folder", plr)
folder.Name = "leaderstats"
local gems ="IntValue", folder)
gems.Name = "Gems"
local Class ="StringValue", folder)
Class.Name = "Class"
Class.Value = "Choosing"

	-- StatsDataStore
	local Ser = game:GetService("DataStoreService")
local Stoarge = Ser:GetDataStore('StatsDataStore')

		local key = plr.UserId
		plr.leaderstats.Gems.Value = Stoarge:GetASync(key, plr.leaderstats.Gems.Value)
		plr.leaderstats.Gem.value = Stoarge:GetAsync("-Class".. plr.UserId, plr.leaderstats.Class.Value)
		local Ser = game:GetService("DataStoreService")
		local Storage = Ser:GetDataStore('StatsDataStore')
	   local work, errorn = pcall(function()

	 Storage:SetAsync(plr.UserId, plr.leaderstats.Gems.Value)

What I have:

What I want it to look like[example]:

1 Like

The Solution

Save your data in a table with special indexes to help make your data clearer.

How To Do It

Hiw to store data in a table like fashion:

local data = {}
data.gems = plr.leaderstats.Gems.Value
data.coins = plr.leaderstats.Coins.Value
--You can add a ton of these
Storage:SetAsync(plr.UserId, data)

local data = Storage:GetAsync(plr.UserId)
if data then
    plr.leaderstats.Gems.Value = data.gems
    plr.leaderstats.Coins.Value = data.coins

If you have any more questions, feel free to ask them.

Disclaimer: You should use pcalls with your datastore requests, I did not include them this time to make it easier to understand


I know for errors etc I am just improving on the code for now



Do you have any further questions? If you do not, glad I could help.

To answer your original question: You could store data on multiple keys, but you may experience throttling (Roblox limits the number of requests you can do). It is easier to store data in a table, as datastores have a max character limit of 260,000 characters, which will rarely be reached.


No This is perfect I got it to work :smile: ty


If you found my post as a solution, make sure to mark it as one so others can find it easily.

If you didn’t, that’s fine: I can help you solve the problem.


Instead of using 30 unneeded characters, hit the heart button. We understand. (:

1 Like