What can I use os.time for?

the title speaks for itself

What can I use os.time for?

You could find out how much time has passed from timeX to timeY, for example:

local time1 = os.time()
task.wait(5)
local time2 = os.time()

local timePassed = (time2 - time1)
1 Like

can you add comments to explain to me how this works? be descriptive

  1. Debounces
  2. Daily/Monthly rewards
  3. Daily/Monthly leaderboards
  4. math.random seed generation

Hey what’s math.random seed generation?!

os.time() returns the number of seconds since 1st January 1970 00:00 and will update every second, so in this case timePassed will be 5

lua math.random is a pseudo-random generator, by changing the seed with math.randomseed(os.time()) the number sequence that is more-likely to be generated changes.

so do I always need to put a wait?

If I wanted to make a daily reward system, How would I detect the time [player] was away if they left?