Run A Function Every 24 Hours

I’m Making a Season Pass for My Game. Its Like you Get Challenges Every 24 Hours And You Get Rewards Completing them.

I Have Made a function to Randomly Give Challenges to The Player But I Have No Idea How I Could Call the Function Every 24 Hours. I Think this Can be Done Using os:time() But I Dont Know How.

I Just Need Some Help Regarding This.

Use"!*t") to get the current time in UTC time. It returns a table like this:

  ["day"] = 20,
  ["hour"] = 7,
  ["isdst"] = false,
  ["min"] = 14,
  ["month"] = 2,
  ["sec"] = 13,
  ["wday"] = 7,
  ["yday"] = 51,
  ["year"] = 2021

More info on that here: os

Basically, save the “last called at” time by inserting the result of into a DataStore when a new challenge starts. Check that value when a player joins.

Here’s the basic flowchart:


you’ll need to track the start time against the system time.

1 Like

1 year later we have a simple solution task.wait(90000) :slight_smile: