I’m trying to make a global countdown wall, and it shows all 38 timezones. however, several timezones are off by 30 or 45 minutes rather than an hour. I’m using a number value to keep track of the minute offset, but eventually the numbers become negative numbers rather than rolling back to the next hour like I want them to. How do I fix this?
Here’s what the countdown shows, I want it to say 4 hours, 50 minutes instead of 5 hours, -10 minutes
Here’s the Script:
local RunService = game:GetService("RunService")
local targetTime = os.time({year = 2020, month = 12, day = 24, hour = 12, min = 0, sec = 0})
local cityName = script.Parent.CityName.Value
local cDText = script.Parent.SurfaceGui.Countdown
local utcOffset = script.Parent.UtcOffset
local minuteOffset = script.Parent.MinutesOffset
local timeDif = 12
while true do
wait(0.5)
local diffSeconds = targetTime - os.time()
local countdown = os.date('!*t', diffSeconds)
local offset = countdown.hour - utcOffset.Value
local hour = offset - timeDif
local minutes = countdown.min - minuteOffset.Value
if diffSeconds <= 0 then
cDText.Text = ("It is already December 25th here")
else
cDText.Text = (("%i days, %i hours, %i minutes, and %i seconds until Dec. 25th"):format(countdown.yday, hour, minutes, countdown.sec))
end
end