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

Hour/Min/Sec - systeme, how to correctly make ?

I make a "Happy New Years Simulator" and i must created a television with date and hour/min/sec, for the date, it ok, but for the Hour/Min/Sec, i have a some worries, can you help me for fix this?

Script1 - No Error

local Min = script.Parent.Min
local Sec = script.Parent.Sec


while wait(1) do
	Sec.Value = Sec.Value+1
	if Sec.Value > 59 then
		Min.Value = Min.Value +1
		Sec.Value = 0
	end
end

Script2 - No Error

local Hour = script.Parent.Hour
local Min = script.Parent.Min
local Sec = script.Parent.Sec


while wait() do
	if Min.Value and Sec.Value < 10 then
		script.Parent.Text = Hour.Value..":0"..Min.Value..":0"..Sec.Value
	elseif Sec.Value > 10 then
		script.Parent.Text = Hour.Value..":0"..Min.Value..":"..Sec.Value
	elseif Min.Value and Sec.Value > 10 then
		script.Parent.Text = Hour.Value..":"..Min.Value..":0"..Sec.Value
	end
end

it has no error, just it not work correctly

2 comments

0

What's it do that's wrong? What's "not work correctly" mean?

0

The système is not optimal, i search a better way of doing things

1 answer

Err this is kind of difficult, but you should be doing something like this. You should just do like minutes and seconds b/c thats when the real countdown starts. but here :

function secondstotimer(seconds)
	local minutes = math.floor(seconds / 60)
	local remainingseconds = seconds % 60
	if remainingseconds <= 0 then
	remainingseconds = "00"
	elseif remainingseconds <= 9 then
		remainingseconds = "0" .. tostring(remainingseconds)
		else
		 remainingseconds = tostring(remainingseconds)
		end
	return tostring(minutes) ..":" .. remainingseconds
end

I'm just kind of guessing cuz idk rlly know where u put ur gui and stuff but err u can just use this for reference and go from there. hope it helps!

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