Is it better to make multiple datastore for multiple values or make a single datastore containing a table with all the values?

Is it better to make multiple datastores for multiple values or make a single datastore containing a table with all the values?

local stats = {
Coins = 1,
Levels = 2,
}
DataStore:SetAsync(tostring(player.userId).."stats", stats)

or

local Coins = 1
local Levels = 2

DataStore:SetAsync(tostring(player.userId).."coins", Coins)
DataStore:SetAsync(tostring(player.userId).."levels", Levels)

I personally, although with not much experience, it depends on how many times you are going to change the value. If you change it for multiple different reasons, e.g. You can buy coins, but coins update every 5 seconds, I personally would go for the second option, however to keep everything neat and easy to access then I would use the first one.

2 Likes

A table is much better because you end up spending much less requests to load and save the data.

4 Likes

Better a table, because you make less requests to the server

1 Like