Execute code weekly

Hi, is there a way to execute a code weekly at a specified time or on a set date? I’m trying to make a Tax System and I want the players to pay them weekly. I got the code for the Tax but can’t figure out the execution…

For sure, u can compare an index day with actual date. If they match more than 7 days execute something.


local _7daysBefore = 1626839830
if os.time() >= _7daysBefore + 24 * 7 * 60 * 60 then
 -- do something

use cron
i would create a JS resource and execute events with cron

-- Execute task every monday at 18:30
function CronTask(d, h, m)
  if d == 1 then
    print('Task done')

TriggerEvent('cron:runAt', 18, 30, CronTask)