local TimeLimit = 360 TimerStart() for i = TimeLimit, 0, -1 do Time = "Time: " .. tostring(math.floor(i / 60)) .. ":" .. tostring(i % 60) --TickSound() G_MSG.Value = Time wait(1) end
When the time turns at 5:09 it turns to a 5:9 instead of 5:09 as i want it to!
Help!?
string.format
When you hit 09, Lua doesn't see the leading 0s and just turns it into 9 as a string. The solution is to look into string formatting to make sure that it knows you want the leading 0s.
string.format( 'Time: %.1d:%.2d', -- % means it's a new symbol, .1/.2 is how many places (As a minimum), d means a number (With no decimal places) time/60, -- Our minutes time%60 -- Our seconds ) --> 5:09