How can I get a Data store's key from a value?

For example, instead of getting a value from a key, can you put in a value, and it will return the key?

2 Likes

Unless you’ve got some sort of dictionary telling you which values are stored under certain key, you can not do that.

1 Like

Dang it :sad: I can only store integers in ordered data stores, not player ids.
(30 charssss sss)

player id is an integer though

My bad, I didn’t think of playerIDs that way. Can you store a dictionary in ordered data stores?

But when I get an ordered sync, how will it know which dictionary should be on top of the list?

When looping through data, v.key gives you player’s place on the leaderboard

for i, v in pairs(data) do
    print(v.key..", "..v.value) --> 1, some value
end

But if the values in the data store are dictionaries, how will the computer choose which one should be on top of the list? Sorry if I’m not explaining my question that well.

I’m not 100% sure if that’s how it works, but if we’re thinking logically, v.value.Points should give you the number (Points is just an example btw).
Here’s an article about ordered datastore if you need more info about it.

I already understand how they work, but nvm. I’ll just store leaderboards a different way.

You cannot store an array in an orderedDataStore and have it sorted.

1 Like

Ok, thanks for clearing things up.

That wasn’t really my original question, but I’ve given up.

The answer to your question is no. There’s nothing unique about a value that would differentiate from another.