function doClock(undif) if debounce2 == false then local undif = 0 local debounce2 = true local DefaultTimeMinutes = mapStorage.DefaultTimeMinutes.Value local MinutesLeft = DefaultTimeMinutes local SecondsLeft = (MinutesLeft * 60) - 1 local MinutesLeft = MinutesLeft - 1 while SecondsLeft ~= 0 do local SecondsLeft = SecondsLeft - 1 -- i wanna check if a minute passed, remove 1 from the minute value wait(1) end end 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.
local minutesLeft local secondsLeft function removeMinutes() minutesLeft = minutesLeft - 1 print(minutesLeft.. " minutes and: " .. secondsLeft.. " seconds left.") -- Prints the time left end function removeSeconds() secondsLeft = secondsLeft - 1 print(minutesLeft.. " minutes and: " .. secondsLeft.. " seconds left.") -- Prints the time left. end function doClock() local DefaultTimeMinutes = mapStorage.DefaultTimeMinutes.Value local MinutesLeft = DefaultTimeMinutes local secondsM = MinutesLeft * 60 delay(1, removeSeconds()) delay(60, removeMinutes()) 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.