How to make a 7 days countdown?

Hi there,
I want to make a live event for my new game and I would like to have a 7 days countdown before the event.

I already tried a few scripts countdown with hours, minutes and secondes and I added the days but it didn’t work.

Could you help me find a script that works ?

Thanks in advance,
Fabrice

2 Likes

You can use os.time for this.

To get the time exactly 7 days from now, you can find the os.time timestamp by adding 7 days (in seconds) to the timestamp right now.

local SevenDaysFromNow = os.time() + 60*60*24*7

Now that you have your timestamp, you can use os.date() to translate this into date and time.

Here’s the complete reference: os | Documentation - Roblox Creator Hub

1 Like

You would use something in this sorts:

local function Format()
string.format("%d:%02d:%02d:%02d", seconds/86400%7, seconds/3600%24, seconds/60%60, seconds%60)
end)

local UnixTimestamp = 00000 --Insert the Unix timestamp of when the countdown ends.

while true do --This will loop your countdown so it's updated.
	local Seconds = UnixTimestamp - os.time() --This is where we do our countdown.
	print(Format(Seconds)) 
       wait(1) --This is the time your countdown will be updated.
end

Your data can always be updated and changed as well! You can do this by replacing: print(Format(Seconds)) and the format function. Some examples can be using NumberValues, often referred to as IntValues, or using this on GUI (In the case you do GUI, do NOT remove the format functions, yet change the value of the text label with proper formatting).

Some RESOURCES that might be helpful would be:

Os.time week countdown - #4 by Usering
os | Documentation - Roblox Creator Hub

Other possible solutions might include utilizing things such as tick(). Documentation for tick() can be found here:

Tick() How do I use it?

4 Likes