Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do I make a 24 hour timer for a daily login reward?

Asked by 3 years ago

How do I make a 24 hour timer for a daily login reward?

I want it so every 24 hours a player can receive an award of money. (Similar to Bloxburg) How would I do this?

1 answer

Log in to vote
3
Answered by
TickoGrey 116
3 years ago

24 hours = 86400 seconds

os.time will tell you what time it is in UNIX time, the clock of seconds that has been ticking since January 1st 1970!

so if we save the os.time when the player joins, we can detect when the player joins we can do current UNIX time - last seen UNIX time then we take the answer, if its more than 86400 then the player has joined 24 hours ago and you can carry out with rewarding them!

helpful links: https://developer.roblox.com/en-us/api-reference/class/DataStoreService https://en.wikipedia.org/wiki/Unix_time https://developer.roblox.com/en-us/api-reference/lua-docs/os

if this helped then be sure to upvote or mark as answer! as always please reply to this if you have any questions or need more help

0
What if they changed their time on their OS? So they could change the time and rejoin over over again to get more reward. Block_manvn 395 — 3y
0
this is not something that could happen, the time is being taken from roblox's servers which cannot have their times changed by any client TickoGrey 116 — 3y
0
Thank you! This helped and I upvoted. soccerstardance251 29 — 3y
Ad

Answer this question