I'm making a script where it counts down from 24 hours. How do I fix this script to count down properly?
local function CountDown()
if script.Parent.Visible == true then
local RawTime = workspace.ShopKeeper.Timer.Value
local Hours = math.floor(RawTime/3600)
RawTime = RawTime - (Hours * 3600)
local Minutes = math.floor(RawTime/60)
local Seconds = RawTime - (Minutes * 60)
if string.len(tostring(Minutes)) == 1 then
Minutes = "0"..Minutes
end
if string.len(tostring(Seconds)) == 1 then
Seconds = "0"..Seconds
end
local TimeString = "Inventory refreshes in: ".. Hours..":"..Minutes..":"..Seconds
script.Parent.Time.Remaining.Text = TimeString
end
end
CountDown()
workspace.ShopKeeper.Timer.Changed:connect(CountDown)

3 comments
string.format("%d:d:d", Hours, Minutes, Seconds) is all you need to make a digital timer format. What is this mess?
The format is actually "% d : % 0 2 d : % 0 2 d" without the spaces. The site sucks at displaying patterns
This is the first time I've done a timer like this before, some explaining would be great if you could do so