Getting multiple values for a leaderboard

Hello!
So basically what I want to do is make two leaderboards: “Most time played” and “Top Donations”.
Playtime and donation amount are both stored into one table inside a datastore.

Now I had a leaderboard setup before, but that was for only one value and since I got a datastore with two values inside a table now I can’t seem to figure out how to get the second value out of the datastore as well.
Here’s an example of what it looks like for only one value:

	for a, b in ipairs(top) do
		local userId 		= b.key
		local minutes 		= b.value
		local username 		= "[ERROR]"

		local s, e 			= pcall(function()
			username 		= SVC_Players:GetNameFromUserIdAsync(userId)
		end)

		if not s then
			warn("Failed to get name for " .. userId .. ": " .. e)
		end
		local image 		= SVC_Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size180x180)

		table.insert(data, {username, minutes, image})
	end

I thought I could use that and get the second value out of it as well, but I’m out of ideas of how to get the second value.

Thanks in advance!

2 Likes
b.Value

Shouldnt this return the table?

1 Like

I tried to debug it using prints and it only printed the amount of minutes instead of a table.
Screenshot 2022-08-22 142526

2 Likes

Print b itself

.

1 Like

Forgive me, I just figured out it wasn’t the actual minute count.
Yeah it just printed a table. But I’m still not quite sure how I’ll be able to get the actual value out of it.

1 Like

Since it printed the table, get the values by there index, or however you saved them.

1 Like

Thanks for helping me with this by the way, I really appreciate it.

I went ahead and did some more prints and it really seems to just be b.value = 1 and the rest is just nil.
It might not get the things I need. I’ll try and do some more debugging.

1 Like

It the b prints a table, print #b

Just done that, it prints “0” so the table is empty.

2 Likes

Alright I found out what was going on at some point. Now I’m being greeted with the “103: Array is not alloawed in data stores.”-error. I’ve done a bit of digging around and apparently arrays don’t work with GetOrderedDataStore().

1 Like