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

Script is not counting down from 24 hours, why is this?

Asked by
Vxpper 101
4 years ago

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)
0
string.format("%d:d:d", Hours, Minutes, Seconds) is all you need to make a digital timer format. What is this mess? programmerHere 371 — 4y
0
The format is actually "% d : % 0 2 d : % 0 2 d" without the spaces. The site sucks at displaying patterns programmerHere 371 — 4y
0
This is the first time I've done a timer like this before, some explaining would be great if you could do so Vxpper 101 — 4y

Answer this question