✓ Accepted answer
I'll show an example here of using os.date first. I have some suggestions at the end.
local dateTable = os.date("!*t")
if dateTable["year"] == 2019 and dateTable["month"] = 7 and dateTable["day"] = 4 then
else
end
That check will obviously have to go in a loop. If you want something more granular in terms of time (maybe your event lasts only 3 hours) look into the os.date documentation here for what else you can find in the dateTable ... https://developer.roblox.com/en-us/api-reference/lua-docs/os.
What I would end up suggesting instead is that if this is a one-off event then you can compute the timestamp ahead of time (something used in computer science to signify a moment in time by the number of seconds elapsed since the "UNIX Epoch" (https://en.wikipedia.org/wiki/Unix_time)) and then check os.time() against it. os.time() gives you the number of seconds. What I like about this is it becomes much clearer how to do time intervals. For example, say I want a july fourth celebration this year to start at midnight in the UTC timezone and last for 10 hours after that. I went to a website https://www.unixtimestamp.com/ and found out that the timestamp I want it to start at is ... 1562198400 (seconds since the unix epoch).
while true do
if os.time() >= 1562198400 and os.time() <= 1562198400 + 10 * 60 * 60 then
else
end
wait()
end
EDIT: An epiphany. We don't actually need to do loops to wait for the right time, we can actually use wait with this last method here ...
local servertime = os.time()
local eventstart = 1562198400
local diff = eventstart - servertime
if diff > 0 then
wait(diff)
end
print("woop woop")
2 comments
os.date requires one of the two arguments: "!*t" or "*t". This will make the function return a table that can be indexed with many keywords, like "day," "year," "month," "sec," and "hour."
um