Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Minutes to seconds script - not efficient when seconds switch from over 60 to below?

function MinsToSecs(dec)
	local MinutesAndSeconds = tonumber(dec)
	if MinutesAndSeconds/60 <= 1 then
		return math.floor(MinutesAndSeconds % 60)
	else
		if MinutesAndSeconds % 60 < 10 then
		return math.floor(MinutesAndSeconds / 60)..":0"..(MinutesAndSeconds % 60)
		else
		return math.Floor(MinutesAndSeconds / 60)..":"..(MinutesAndSeconds % 60)
		end 
	end
end

function intermission()
	local intermissionTime = 70
	for i = 1, intermissionTime do -- in seconds
		wait(1)
		intermissionTime = intermissionTime - 1
		message.Value = " "..MinsToSecs(intermissionTime).." "
	end
end
I've made a minutes to seconds function to work with the intermission. I tested it, and between the seconds switched from over 60 seconds to under 60 seconds, the text for the timer gui (called message in the portion of the script showed above) switched to 0 for about a second and switched back to the regular time. I have no idea how to fix this, but does someone else?

1 answer

You could try something like this:

function MinsToSecs(dec)
    local MinutesAndSeconds = tonumber(dec)
	local Minutes = 0
	while MinutesAndSeconds > 60 do
		Minutes = Minutes + 1
		MinutesAndSeconds = MinutesAndSeconds - 60
	end
	local Seconds = math.floor(MinutesAndSeconds)
	return Minutes .. ":" .. Seconds
end

function intermission()
    local intermissionTime = 70
    for i = 1, intermissionTime do -- in seconds
        wait(1)
        intermissionTime = intermissionTime - 1
        message.Value = " "..MinsToSecs(intermissionTime).." "
    end
end

2 comments

1

Errr.. Didn't work as planned. When the seconds part goes has a number less than two digits, the first digit doesn't switch do a 0 like the original script that I posted. Thanks for trying, though

0

Ahh, I figured out the problem now. I needed to switch where the if statements are to make the script run more efficiently.

This discussion is preserved as it was. New answers, comments, and votes are closed.