Saving lots of data in a single key?

I was thinking of is it possible saving multiple strings/values in a single key, like I think this is an a not really effective way of saving data. (i might be wrong that’s how just i feel)

local data1 = datastore:GetDataStore("ribixdata")
local data2 = datastore:GetDataStore("bobuxdata")

bobux.Value = data2:GetAsync(player.UserId) or 0
data2:SetAsync(player.UserId, bobux.Value)
ribix.Value = data1:GetAsync(player.UserId) or 0
data1:SetAsync(player.UserId, ribix.Value)

Could it be better if I save both stats in a single key? (speaking of the server limits)
Is it possible to save both stats in a single key?
How do I do that?

You can save table to datastore, datastore have size limitation but its 4000000 characters, so i think you should’nt care about limitation

Hmm, I wonder how can I get data from a table?

For example,

local datastore = datastoreservice:GetDataStore("somedatastore")

local DataToSave = {
  Key1 = "Hello!", -- Keyname = Value
  Key2 = 1234
}

datastore:SetAsync("somekey",DataToSave)

local GotData = datastore:GetAsync("somekey")

print(GotData.Key1) -- Prints "Hello!"
print(GotData.Key2) -- Prints 1234
1 Like