Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I add a minute timer for my game countdown?

Asked by 4 years ago

I am currently using a loop to countdown the amount of time left in my game. The current amount of time a round in my game lasts for is 600 seconds or 10 mins. How would I make it countdown from 10:00 instead of 600?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

This script is very short because it is SO easy;

also set; "ResetOnSpawn" enabled in the current screengui you are editing

01local timer = script.Parent
02local minutes = 2
03local seconds = 19
04 
05repeat
06    if seconds <= 0 then
07        minutes = minutes - 1
08        seconds = 59
09    else
10        seconds = seconds - 1
11    end
12    if seconds <= 9  then
13        timer.Text = tostring(minutes)..":0"..tostring(seconds)
14    else
15        timer.Text = tostring(minutes)..":"..tostring(seconds)
16    end
17    wait(1)
18until minutes <= 0 and seconds <= 0

Explanation

If the seconds is smaller than 0 then the minutes is equal to itself - 1 else the seconds will subtract by themselves

and you know the rest

Ad

Answer this question