How do you live countdown [I need help]

I need help, does anyone know how to create this live countdown?20201020_151943

6 Likes

What do you mean by a live countdown?

  • In-game
  • Website
  • Other
1 Like

In Game, You know how? please help me

1 Like

I don't have experience with Lua, but I asked so that maybe someone knows how to help you. Sorry.

2 Likes

You should use os.time but idk how

2 Likes

You can have a look here!

2 Likes

That’s AngelD23’s countdown. You can find countdown tutorials on YouTube. They aren’t reliable as they have broken for me before, but until you learn how to script really good, you might have to use a tutorial.

1 Like

who is angeld? Maybe you can help me

1 Like

If you need a live countdown tutorial for an event or something, try @Alvin_Blox’s tutorial on it. He explains it pretty well.

So what you mean by live countdown for a live event or just a countdown
Live countdown you can use the video above but for a regular count down you can use this video down below

1 Like

Im pretty sure you know who he is. Especially if you have his game favorited.

“Angeld23” the creator of petanzone?

Yes. As far as im aware there is no other Angeld23

1 Like

I have a few questions.

  1. Is this countdown going to be the same for everyone in the game? Or will it be different countdown times for each player?
  2. When do you want this countdown to start and end?

If you want a countdown that’s synced with every other player, as in, whatever you want to happen happens at once on all clients, then a good solution would be to set when you want it to occur in a script. I know this sounds kind of obvious, but at the most basic level it’s just a timer with the same end time across all clients.

For example, if I wanted a script to print “Happy Halloween!” on October 31st, 2020, at 12:00 AM GMT, the goal time would be 1604102400.
This is because the Unix epoch is the amount of seconds since January 1, 1970 (I believe)

I could set the goal time: local goal = 1604102400

Reminder, this is the epoch in seconds for the date you want the event to happen on. Like I said earlier, this is set to 2020/10/31 at 12:00 AM GMT.

Then, I could get the current epoch using os.time(): local current = os.time()

So, if you got the epoch at, say, 1970/1/1 at 01:00 AM GMT (so 1 hour since the Unix epoch is set to count), then the epoch would equal 3600, since an hour is 3600 seconds long.

Then, I could get the seconds until the goal: local secondsLeft = goal - current

So, if your goal is 7200 (1970/01/01, 02:00 AM GMT), and your current epoch is 3600 (1970/01/01, 01:00 AM GMT), the result would be 3600, so the goal would be 1 hour away.

Finally, I could parse it into human-readable time:

local parsedSeconds = secondsLeft % 60 --the % represents the "modulo" operation, also called "x mod y". It gets the remainder (so if it was 70, 70 mod 60 would be 10)
local parsedMinutes = secondsLeft / 60 % 60 --once again, we use the modulo operation to get a readable amount of minutes
local parsedHours = secondsLeft / 3600 --3600 seconds in an hour (you can further convert this into days by dividing by 24)

These are useful for displaying in GUIs, since instead of displaying a huge number which is isn’t representative of how long you have to wait, you can break it up into smaller, more understandable pieces.

And, when secondsLeft <= 0, we can do what we wanted to do, which in this case was print “Happy Halloween!”

Keep in mind that this is synced to the GMT/UTC timezone, instead of yours/the player’s.

2 Likes