Hello, I am attempting to make a working digital clock, it worked just fine until I added a piece of code.
No error codes in Output,
(I know it’s a bit excessive.)
Script:
local hour
local minute
local extrazero = 0
local timevalue = script.Parent.Parent.Parent.Parent.Time
local pause = script.Parent.Parent.Parent.Parent.Paused
while true do
wait(5)
-- Issue starts from code below.
if string.len(timevalue.Value) == 3 then
hour = string.sub(timevalue.Value, 1,1)
minute = string.sub(timevalue.Value, 2,3)
elseif string.len(timevalue.Value) == 4 then
hour = string.sub(timevalue.Value, 1,2)
minute = string.sub(timevalue.Value, 3,4)
end
-- The rest of the code works like it is supposed to.
if pause.Value == false then
if hour == 12 then
if minute == 59 then
hour = 1
minute = 00
script.Parent.Text = (hour .. ":" .. extrazero .. minute)
timevalue.Value = (hour .. extrazero .. minute)
else
if string.len(minute) == 1 and minute ~= 9 then
minute += 1
script.Parent.Text = (hour .. ":" .. extrazero .. minute)
timevalue.Value = (hour .. extrazero .. minute)
else
minute += 1
script.Parent.Text = (hour .. ":" .. minute)
timevalue.Value = (hour .. minute)
end
end
elseif minute == 59 then
hour += 1
minute = 00
script.Parent.Text = (hour .. ":" .. extrazero .. minute)
timevalue.Value = (hour .. extrazero .. minute)
else
if string.len(minute) == 1 and minute ~= 9 then
minute += 1
script.Parent.Text = (hour .. ":" .. extrazero .. minute)
timevalue.Value = (hour .. extrazero .. minute)
else
minute += 1
script.Parent.Text = (hour .. ":" .. minute)
timevalue.Value = (hour .. minute)
end
end
end
end
Photo showing the layout:
The issue is that the minutes keep going, even though it has passed 60 minutes.
Any help would be appreciated!