Add the variable like so: local StartTime = 1608879600Įpic. First, lets a variable for math.Floor! We use math.Floor for the big brain math. We will need to use a LOT of big brain math to determine how many days that are left, hours that are left, ect. ![]() Now, we will begin making the actual countdown text change. Like so: local StartTime = 1608879600Īnd if you check the Output, it will print how much time (in seconds) is left until your chosen epoch time! ![]() Now, we will add the else inside the if statement, with the print! The else is checking if the countdown is NOT done counting down, then it will print how much time is left. This will be how much time is left! We will subtract the StartTime variable, to the currentTime variable. ![]() So if the countdown isn’t done counting down to 0, then it will print how much time is left!įirst, lets make a Variable Inside the loop. Simple, but works well! Now, to test out if everything is in order, we will put an else inside the if statement. Whatever is inside here is what happens when the countdown hits 0!. We will do this by using a simple if statement. And if it is, then we will tell the script what to do. So simply use os.time() to tell the current epoch time! Like so: local StartTime = 1608879600Ĭool, huh? Now, we will code the part that has the script check if the currentTime is equal to StartTime. Why inside the loop? Because if its outside the loop… It will only tell us the current time when the script runs, and not every second like we want it to. Now, we will create a Variable that is the current time epoch! Make sure this variable is inside the Loop. This will make it wait 1 second before updating the countdown! Like so: local StartTime = 1608879600 Now, we have to add a wait(1) Inside our loop. Open up the script, and now we can create the Loop that counts down! Inside your script, add a simple While loop. Wonderful! Now, we can continue with our code! Now, you can simply drag the Script into the Countdown. Your workspace should look something like this: Once you grab that, Insert it into your game, and put it into Workspace. Okay, now that we have our basic variables, inside a Server Script inside of Workspace, we will begin designing our Countdown! Here is a basic countdown Model Link I Created: ![]() Local TweenService = game:GetService("TweenService") This is totally up to you, but if you want a cool fade away effect once the timer hits 0, you might want to add this variable for reference! Like So: local StartTime = 1608879600 The variable is the epoch that we want it to Countdown to! And now, we want to add another variable. And after setting it to Local time, just insert the date! Now that you know how to get your date, lets begin coding. Make sure that its set to Local Time and not GMT. The First variable, will be our time that we want the Countdown to hit 0! Go to to convert to your time! For this example, Im going to make the countdown, countdown to December 25th, 2020. Epoch is extremely useful, and you might use it a lot in the future. We use Epoch to tell our code how much time is left. Without further a do, lets get to it! About EpochĮpoch is the amount of time that has passed since January 1st, 1970. Hello! Today we are going to be creating a Live Countdown across all servers.
0 Comments
Leave a Reply. |