I am planning to start a 3 minutes firework event every o’clock on coming 2 days.
The firework show is enclosed in a function, so I want to start it every one hour.
(like 7:00 am, 8:00 am, …)
I know while loops and task.wait() but it seems to be too long to wait an hour.
Also I know Datetime:Now() to get current os time, but I dont know how to use this to schedule the event occur every one hour.
local function startFireworkShow()
-- Your code
print("Test");
end
while true do
local currentTime = DateTime.now():ToUniversalTime();
local minutes = currentTime.Minute;
local seconds = currentTime.Second;
-- Calculates the time remaining until the next hour
local waitTime = (60 - minutes) * 60 - seconds;
task.wait(waitTime);
startFireworkShow();
end