Convert seconds into minutes

This section of a round system:

for i = 120, 0, -1 do
	Status.Value = "<b>" .. i .. "</b> left"
	task.wait(1)
end

What is Status:
Status is a value in ReplicatedStorage which shows the current announcement or whatever at the top of all the players screens.

Problem:
120 is amount of seconds, but if it will just show the seconds of course as there is no seconds to minutes conversion. I saw some fourms but I wasen’t sure how to set it up, when I did I failed. Any help would help me out.

If it helps to resolve this, the UI that shows the status simply does a while wait() loop for setting the text the value of Status.

Is this what you mean?

Yes, but I am not sure how to apply the “convertToHMS” to the section I showed.

Like this, use i as the input to the converstation.

for i = 120, 0, -1 do
    local result =  converttoMS(i)
	Status.Value = "<b>" .. result .. "</b> left"
	task.wait(1)
end
2 Likes
function Format(Int)
	return string.format("%02i", Int)
end

function convertToHMS(Seconds)
	local Minutes = (Seconds - Seconds%60)/60
	Seconds = Seconds - Minutes*60
	local Hours = (Minutes - Minutes%60)/60
	Minutes = Minutes - Hours*60
	return Format(Hours)..":"..Format(Minutes)..":"..Format(Seconds)
end

for i = 120, 0, -1 do
	Status.Value = "<b>" .. convertToHMS(i) .. "</b> left"
	task.wait(1)
end
6 Likes

Thanks a lot worked perfectly with no errors!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.