I am trying to make a leaderboard (global) that uses values saved with datastore in string format ExY (3e45 for example) however i dont know much about leaderboards. I have tryed experimenting with free models but cant get it right. Anyone know how i can do this? (i tried using the eternitynum functions but still)
i make games in EternityNum all the time, and it’s super easy to store values in leaderboards.
you can use EternityNum.lbencode() for the values you want to store. for example:
DataStore:UpdateAsync(v.UserId, function(Value)
return EternityNum.lbencode(stateExample)
end)
this encodes your value so it’s safe to store in a datastore.
to get values back for displaying in eternitynum, use EternityNum.lbdecode():
local decoded = EternityNum.lbdecode(stat)
Value.Text = EternityNum.short(decoded)
As i said i do not know how the leaderboards work and i tried using functions but i cant make it work all together
Leaderboards use ordered datastores, ordered datastores are different than normal player datastores, and their main benefit is that they can mass-fetch data(for example 100 rows at once). Also the data inside them is sorted(so if you fetch the first page you should get the players with the higher values).
One major limitation ordered datastores have is that they require all numbers to be integers, but very large or very small numbers aren’t integers, they are floats, so if you try to save them you get an error. What lbencode and lbdecode does is that it converts a float to an integer and the reverse so you can store them inside ordered datastores. It also maintains their order so the positions players load in are correct(the first player remains first, etc).
So basically what you do is that when you write to the ordered datastore, instead of writing the raw EternityNum value, you write the encoded value lbencode returns. When you fetch the data, it is encoded, so you run lbdecode on it before showing it on leaderboards.
You can think of it as serializing and deserializing data, it’s the same concept but for a single thing.
I’ll link a devforum tutorial that I found helpful, but just note: you should have some decent scripting and building knowledge, and also, you’ll have to replace points service with something that isn’t deprecated.
i tried to modify a script but it always, no matter what return " ", i mean i can try it again but dont see why would it work this time
i did menage to get data, but it is wrong? i went to get a value that is abt 1e56 but it displays 20k which is nowhere to be seen
my bad when i got back the old model i forgot i switched up what i used for it lol, it had old data saved it turns out it works now. somehow.
thanks for help
Uh um, you didnt see nothing shhh
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
