I know it’s quickly made, but why LocalScript
instead ModuleScript
for modules, and why not just store it by seconds and use divide to get minutes and hours, and why not functions instead of setting them to TextLabel?
Or alternatively you could use one of my module, CLDRTools which supports plurals for seconds.
local CLDR = require(game.ReplicatedStorage.CLDRTools)
local TimeSpan = require(game.ReplicatedStorage.DateTime).TimeSpan;
local en = CLDR.Locale.new('en', 'US')
function cleantime(t, display_extra)
if display_extra then
if t >= TimeSpan.FromDays(1) then
return ('%s, %s, %s, %s'):format(
CLDR.Units.FormatUnit(en, t.Days, 'duration-day'),
CLDR.Units.FormatUnit(en, t.Hours, 'duration-hour'),
CLDR.Units.FormatUnit(en, t.Minutes, 'duration-minute'),
CLDR.Units.FormatUnit(en, t.Seconds, 'duration-second'));
elseif t >= TimeSpan.FromHours(1) then
return ('%s, %s, %s'):format(
CLDR.Units.FormatUnit(en, t.Hours, 'duration-hour'),
CLDR.Units.FormatUnit(en, t.Minutes, 'duration-minute'),
CLDR.Units.FormatUnit(en, t.Seconds, 'duration-second'));
elseif t > TimeSpan.FromMinutes(1) then
return ('%s, %s'):format(
CLDR.Units.FormatUnit(en, t.Minutes, 'duration-minute'),
CLDR.Units.FormatUnit(en, t.Seconds, 'duration-second'));
end;
else
return CLDR.Dates.FormatTimeSpan(en, t, 'second', 1)
end;
return CLDR.Units.FormatUnit(en, t.Seconds, 'duration-second');
end;
local secs = 0;
while wait(1) do
secs = secs + 1;
print(cleantime(TimeSpan.FromSeconds(secs), true));
end
1 second
2 seconds
3 seconds
…
59 seconds
1 minute, 1 second
1 minute, 2 seconds
1 minute, 3 seconds
1 minute, 4 seconds