I am working on a game that has multiple different things that operate on a 24 hour system (i.e., 24 hours after a player does [x], do [y]). Most of these just check when the player joins if it has been 24 hours since the last time they did [x].
However, the system I have in place seems very inconsistent, with many players reporting resets much sooner than 24 hours, though I am not sure how that is possible and cannot replicate it myself. Here is my current solution:
function playerDidSomething(player)
local didSomethingTable[player] = {true, tick()+86400}
--this table is saved to a datastore when the player leaves
end
function playerJoined(player)
--first loads the table into didSomethingTable[player], then:
if didSomethingTable[player][2] < tick() then
undoSomething(player)
didSomethingTable[player] = nil
end
end