Since you can only store one integer per player key (per datastore), I’m forced to have multiple datastores if I want multiple integers, which seems a bit too… unnecessary?
Wouldn’t it be better if you were able to store it the same was as in GlobalDataStore? Tables (arrays and dictionaries are not allowed in OrderedDataStore).
Here’s an example:
local DataStoreService = game:GetService('DataStoreService')
local Key1 = DataStoreService:GetDataStore('Key 1')
local Key2 = DataStoreService:GetDataStore('Key 2')
local Key3 = DataStoreService:GetDataStore('Key 3')
-- What you need to do to save 3 values:
Key1:SetAsync(PlayerKey, 1)
Key1:SetAsync(PlayerKey, 2)
Key1:SetAsync(PlayerKey, 3)
-- What you should be able to do:
Key1:SetAsync(PlayerKey, { Hello1 = 1, Hello2 = 2, Hello3 = 3 })
There are probably a few ways around this, however I can’t think of any as it requires multiple datastores in my logic.
I thought so, thanks for the reply anyways.
It’s just a bit dumb in my opinion if you’re going to have a lot of integers, though.
Would be a lot of saving and yielding.
I agree, we should be able to store arrays. You could probably use the scope argument, but that really wouldn’t clean up your code much as you’d have to get each scope and I don’t think the amount of get requests would be reduced either.
I could probably use the scope argument yeah, but wouldn’t it technically be the same datastore in terms of rate-limits per datastore?
You could probably use the scope argument, but that really wouldn’t clean up your code much as you’d have to get each scope and I don’t think the amount of get requests would be reduced either.
You could concatenate the three integer values as a single string value with some appropriate delimiter, and then when you need that data again you’d just need to make a single request to the DataStore and split the integer values by using the string.split() function.