01 | function doClock(undif) |
02 | if debounce 2 = = false then |
03 | local undif = 0 |
04 | local debounce 2 = true |
05 | local DefaultTimeMinutes = mapStorage.DefaultTimeMinutes.Value |
06 | local MinutesLeft = DefaultTimeMinutes |
07 | local SecondsLeft = (MinutesLeft * 60 ) - 1 |
08 | local MinutesLeft = MinutesLeft - 1 |
09 | while SecondsLeft ~ = 0 do |
10 | local SecondsLeft = SecondsLeft - 1 |
11 | -- i wanna check if a minute passed, remove 1 from the minute value |
12 | wait( 1 ) |
13 | end |
14 | end |
15 | end |
Any idea why on how to do that if a minute passed, remove 1 from the minute value? (as said on the comment)
Just add a delay() timer. When a certain time passes, an function will execute.
01 | local minutesLeft |
02 | local secondsLeft |
03 |
04 | function removeMinutes() |
05 | minutesLeft = minutesLeft - 1 |
06 | print (minutesLeft.. " minutes and: " .. secondsLeft.. " seconds left." ) -- Prints the time left |
07 | end |
08 | function removeSeconds() |
09 | secondsLeft = secondsLeft - 1 |
10 | print (minutesLeft.. " minutes and: " .. secondsLeft.. " seconds left." ) -- Prints the time left. |
11 | end |
12 |
13 | function doClock() |
14 | local DefaultTimeMinutes = mapStorage.DefaultTimeMinutes.Value |
15 | local MinutesLeft = DefaultTimeMinutes |
16 | local secondsM = MinutesLeft * 60 |
17 | delay( 1 , removeSeconds()) |
18 | delay( 60 , removeMinutes()) |
19 | end |
So what I just made it's use a function called "delay()" that when certain times passes (in seconds, first argument), then a callback will be fired, in this case the functions.
Hope it helped.