Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

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

Asked by 7 years ago

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

0
What's it do that's wrong? What's "not work correctly" mean? BlueTaslem 18071 — 7y
0
The système is not optimal, i search a better way of doing things NiniBlackJackQc 1562 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

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!

Ad

Answer this question