Script to print ordered datastore not running

Hello there! I’m testing out a script to print out my datastore, but for some reason, when I run it, nothing appears in the output, not even a single error, here’s the script:

local DS = game:GetService("DataStoreService"):GetOrderedDataStore("BCS-Datastore")
local Pages = DS:GetSortedAsync(false, 100, 1, 10e30)
local Top = Pages:GetCurrentPage()
for i, d in pairs(Top) do
	print("#"..tostring(i).." - "..tostring(d.key)..": "..tostring(d.value)) --// Should print out something like "#1 - 123456789: 100", but nothing happens.
end

I don’t see what’s wrong for nothing to print out, so could someone please help me?

image
I tested it with one of my globaldatastores and it worked perfectly fine. It might be with your script that is saving data to the globaldatastore

1 Like

For the saving script, I use the normal :GetDataStore(“BCS-Datastore”), is that a problem?

Oh so the issue here is that Data Stores and Ordered Data Stores are two different things. So you can not access the items in a Data Store like it is an ordered data store.

I hope that makes sense, but just to clear it up more, you have an ordered data store called “BCS-Datastore” that has no data in it. But your Data Store, “BCS-Datastore” has data in it. So you would have to also save your data to the ordered data store as well.

1 Like

Standard ‘DataStore’ API methods are compatible with both ‘DataStores’ and ‘OrderedDataStores’, think ‘GetAsync’. ‘SetAsync’, ‘IncrementAsync’ etc.

The primary difference between the two is that ‘OrderedDataStore’ objects have an exclusive member (method) named ‘GetSortedAsync’.