First of all I would like to start by saying this is not a request, but rather a question. I've seen this in many games and I've always wondered how such implementation is accomplished. For instance, lets take The Mad Murderer into account, how did Loleris implement the daily award system in which you would get a certain amount of credits every 12 hours?
Basically, he saves an integer representing the time that the player last earned the reward. Then, he compares this integer to the current time, and see if more than 12 hours have passed. I'm too lazy to get out my datastore reference to actually write working code, but here's how it would look:
game.Players.PlayerAdded:connect(function(player) if os.time() - getLastRewardTime(player) > 60*60*12 then -- seconds/minute * minutes/hour * hours rewardPlayer(player) end end)
This assumes that the rewardPlayer
function sets the LastRewardTime
that getLastRewardTime
is accessing. If LastRewardTime
doesn't exist, the function returns 0
.
I used os.time()
instead of tick()
for reasons you should read about here. Keep in mind that you should only get relative place visit times from Scripts and not LocalScripts.