How can I change the timer format from seconds to minutes?

function Format(Int)

return string.format("%02i", Int)


function convertToHMS(Seconds)

local Minutes = (Seconds - Seconds%60)/60

Seconds = Seconds - Minutes*60

local Hours = (Minutes - Minutes%60)/60

Minutes = Minutes - Hours*60

local Days = (Hours-Hours%24)/24

Hours = Hours-Days*24

return "Days: "..Format(Days).." Hours: "..Format(Hours).." Minutes: "..Format(Minutes).." Seconds: "..Format(Seconds)


1 Like

Please use code blocks / screen shots to make reading it more elegant.

I tested it but the status value is in seconds format

Send me a screen shot of how the gui looks like in game, like when the timer is running.

Now is an error saying PlayerGui.Timer.TimerScript:5: attempt to perform arithmetic (div) on nil and number

So the text is reset to default text

Send a screen shot of how the time was formatted on gui if you can.

Before the timer is in seconds and now is the text it displays in studio edit mode

I don’t really have much to go off of, so make you typed in tonumber(status.Test) and not tonumber(status).

I did status.value in the script

I meant Value whoops.

-- Character Limit

In status properties it still says seconds format and in the timer text local script it says this error:
PlayerGui.Timer.TimerScript:5: attempt to perform arithmetic (div) on nil and number

Did you input a value into ConvertClock? I have no clue as to why that error would appear.

Yes I did ConvertClock(Time) in the function

I meant did you do this:


Yes I did do that in the script line

Could you send the whole local script again?

local status = game.ReplicatedStorage.Status
local Time = script.parent.Time

function ConvertClock(Time)
	local minutes = math.floor(Time / 60)
	local seconds = math.floor(Time % 60)

	if tostring(seconds):len() == 1 then
		seconds = tostring("0"..seconds)

	return {tostring(minutes), tostring(seconds)}

	local c = ConvertClock(tonumber(status.Value))
	Time.Text = c[1]..":"..c[2]

What type of value is status? If it’s a string value, try changing to to an integer / number value.

I did that but the text is the same as the edit mode text and there are no errors. I did a string value so that status displays Time: (number) instead of (number)

I have no idea what is causing an error like that, hmm.