Hi, I am trying to create a countdown but it does not show the remaining time correctly. It is 3 hours in advance. I tried to change the targetTime but it didn’t work either, I had the same problem.
local RunService = game:GetService("RunService")
local targetTime = os.time({year = 2022, month = 1, day = 1, hour = 0, min = 0, sec = 0})
local connection
connection = RunService.RenderStepped:Connect(function()
local delta = targetTime - os.time()
if delta >= 0 then
local seconds = math.floor(delta) % 60
local minutes = math.floor(delta / 60) % 60
local hours = math.floor(delta / 60 / 60) % 24
local days = math.floor(delta / 60 / 60 / 24)
script.Parent.SecondsText.Text = seconds
script.Parent.MinutesText.Text = minutes
script.Parent.HoursText.Text = hours
script.Parent.DaysText.Text = days
else
script.Parent.SecondsText.Text = 0
script.Parent.MinutesText.Text = 0
script.Parent.HoursText.Text = 0
script.Parent.DaysText.Text = 0
connection:Disconnect()
end
end)
Hi, that didn’t work either, it shows the same as my current code. it is in a localscript and should show the time remaining in the player’s local time.