Hello. I was setting up a countdown timer for a limited-time vehicle for my game. When I tested it, it displayed the wrong time.
Script:
local countdownGui = script.Parent
local countdownText = countdownGui:WaitForChild("CountdownText")
local day = os.time({year = 2022, month = 12, day = 1, hour = 12, min = 0, sec = 0})
while wait() do
local secondsBetween = os.difftime(day, os.time())
local seconds = secondsBetween % 60
local minutes = math.floor(secondsBetween % (60*60) / 60)
local hours = math.floor(secondsBetween % (60*60*24) / (60*60))
local days = math.floor(secondsBetween % (60*60*24*30) / (60*60*24))
local textString = days .. "d:" .. hours .. "h:" .. minutes .. "m:" .. seconds .. "s"
countdownText.Text = textString
if secondsBetween <= 0 then break end
end
How it displays: