You could store it like this, and reset when the two value’s don’t equal each other.
Here’s a little pseudo code
local dateTable = os.date("*t", os.time())
local key = "Y:"..dateTable["year"].." M:"..dateTable["month"].." D:"..dateTable["day"]
local getData = --Get player's data
if getData["DayStored"]~=key then
--New day, reset data and set new key
getData["DayStored"] = key
getData["ActualData"] = 0 --Add to this when they gain cash
end
Glad you found it useful. The same principle would apply for other values, just remember to reset when the day is not the same, and create a separate value to save to other than your long-term storage.
Hello! I want to know how do i set a line where i can set what players cannot appear in the leaderboard, some kind of banned people or developers who wants to test stuff with a high value of “Rebirths” without appearing on the leaderboard.
AwardPoints was discontinued, so pull the value from somewhere else. (It might also just be internet connection) You can look at some of the above replies to figure out how.
I know this is an older post; hope its okay to post here. I wanted to thank ThatTimothy for putting together such a thorough and educational post…and for sharing all of the resources. I actually pulled this model into my first game, and made the points modification suggested in the FAQ, and its worked flawlessly since.
A rookie question: My first game was only saving a single value in the Datastore. In my current game I’m saving many values to a single Datastore using a table. I only need the leaderboard to display a single value (Experience). Should I use a second Datastore to record Experience only, or is there a way to pull just a single value from the table into the leaderboard?
Old working code – I added the yellow highlighted replacing the above line:
New datastore saving – I would like to show only Experience in the board.
OrderedDataStores can only store one numerical value, and will only be able to sort their individual OrderedDataStore. Since a regular DataStore and the OrderedDataStore are completely separate, you must make a OrderedDataStore for each leaderboard you wish to have.
Hey, so I am not the best scripter. I am going to use this as a base to my leaderboard. But, how do I change it to leaderstat values? Because I am still getting to know lua, and it is confusing for me.