OrderedDataStores Error

Hi, I was using Ordered DataStores but I got an error saying “attempt to concatenate string with table. Line 35.” Code:

local dataStore = game:GetService("DataStoreService")
local playerData = dataStore:GetOrderedDataStore("playerData")


local participants = {
	
	["A"] = 900;
	["B"] = 1000;
	["C"] = 910;
	["D"] = 894;
	["E"] = 0
	
}


for username, exp in pairs(participants) do
	
	playerData:SetAsync(username, exp)
	
end



local pages = playerData:GetSortedAsync(false, 3)



while wait() do
	
	local data = pages:GetCurrentPage()
	
	
	for _, exp in pairs(data) do
		
		print(exp.Key .. " - " .. exp.Value)
		
	end
	
	if pages.IsFinished then
		break
	else
		print("---------------")
		pages:AdvanceToNextPageAsync()
	end
end

If anybody has any answer please tell me. :wave:

exp.Value is a table.

I don’t have experience woith DataStores but I can say that

Yeah but I’m printing the key and value.

In your code you are concatenating a string with a table, you can’t do that.
Try: print(exp.Key, exp.Value) instead

1 Like

keeping in mind it will only return the reference to it

1 Like

I tried that before. It’s just printing nil.

Then the value is empty.

303030030

How, I gave each person a value?

I am not knowledgeable in datastores, but I think you can use playerData:SetAsync(username, data) like you did

I don’t understand the pages bit, so I don’t know what’s wrong with your code.

Can’t you just get the exp for each player ingame? With playerData:GetAsync(username)?

No it’s just printing blank. Idk what to do.

Try doing exp.value instead of exp.Value for some reason it’s called “value” inside the table

1 Like

Wait, I just changed exp.Key to exp.key with lower-case. Thanks, I’ll mark you as solution.