Is this the best way to reset every hour?

Basically, im making a system where a dictionary will change its stock every hour, so at 12:00, 1:00, etc. I made this script but I just started learning about os.date so I’m not sure if this is the best way to do this, here it is:

local function resetRosterEveryHour()
	while task.wait(1) do
		if tonumber(os.date("%M")) == 59 and tonumber(os.date("%S")) == 59 then
			restockRoster()
		end
	end
end

coroutine.wrap(resetRosterEveryHour)()

Any help is appreciated, thanks!

1 Like

Why don’t you do this instead ?

while task.wait(3600) do
    restockRoster()
end

Because that would be the age of the server meaning different servers would reset at different times.

Oh okay, you didn’t told it in your main post, that you want every server restock at same time ^^