Hello! I am having a problem where my Countdown is showing the “Rejoin!” Text before the countdown ended inside Game? Inside Studio, It shows 2 hours but in-game is shows the Text it shows after it hits 0. Why is it doing this?
What I mean:
In game ^
In Studio ^
Here is the script I am using for it
wait()
local MF = math.floor
local Next = next
local Tick = tick
local Wait = wait
local Stop = 0
local Timer = 0.5
while true do Wait(Timer)
wait()
local Time = 1634855245 - Tick()
local Days = MF((Time / 60 / 60 / 30) % (250 + 0.250))
local Hours = MF((Time / 60 / 60) % 30)
local Minutes = MF((Time / 60) % 60)
local Seconds = MF(Time % 60)
if Stop == 0 then
script.Parent.Time.Text = Days..":"..Hours.. ":"..Minutes..":"..Seconds.." "
end
if Days==0 and Hours==0 and Minutes==0 and Seconds==0 or Time < 0 then
Stop=0
script.Parent.Time.Text = "Rejoin!"
end
end
Just to ask make use your game published. Another thing is it should be tick() with lowercase. Not sure why, if this is your entire script how come you have if Stop = 0 when stop doesn’t change within the script you showed which is a bit odd. Just one more thing to point out is wouldn’t Time always be a negative? Unless you want it that way?
The timer could be improved slightly. If this is a global timer, I’m not how to help you there, but if it’s a server, I can help you. Of course you can add this into a global timer if you want.
local AMOUNT_OF_TIME = 3600 -- 1 hour in seconds
local textLabel = script.Parent.Time
for i = AMOUNT_OF_TIME, 0, -1 do
-- Not sure if this is the best way but seems like the only way I can think off
local Days = math.floor(i/60/60/60)
local Hours = math.floor(i/60/60)
local Minutes = math.floor(i/60)
local Seconds = math.floor(i%60)
textLabel.Text = string.format("%02i:%02i:%02i:%02i", Days, Hours, Minutes, Seconds)
task.wait(1) -- Waits 1 second
end
-- Anything after here will run after the timer has been completed.
print("Timer Completed")
textLabel.Text = "Rejoin" -- ? You could have this if you need as well
I figured out the problem, it’s just the timestamp, if you change it to something else, it may actually work. Perhaps you could use a timestamp converter to help you.
wait()
local MF = math.floor
local Next = next
local Tick = tick
local Wait = wait
local Stop = 0
local Timer = -1
while true do Wait(Timer)
wait()
local Time = 1634900000 - Tick()
local Days = MF((Time / 60 / 60 / 30) % (250 + 0.250))
local Hours = MF((Time / 60 / 60) % 30)
local Minutes = MF((Time / 60) % 60)
local Seconds = MF(Time % 60)
if Stop == 0 then
script.Parent.Time.Text = Days..":"..Hours.. ":"..Minutes..":"..Seconds.." "
end
if Days==0 and Hours==0 and Minutes==0 and Seconds==0 or Time < 0 then
Stop=0
script.Parent.Time.Text = "Rejoin!"
end
end
This is what it shows in studio
And this is what it shows in Game
It’s still a 4-hour difference, how can I fix this?
Yea it does the same thing, same with any other number I think. But yea it seems to be exactly 4 Hours, and 1 second behind on what it says inside Studio.
wait()
local MF = math.floor
local Next = next
local Tick = tick
local Wait = wait
local Stop = 0
local Timer = -1
while true do Wait(Timer)
wait()
local Time = 1634961600 - os.time()
local Days = MF((Time / 60 / 60 / 30) % (250 + 0.250))
local Hours = MF((Time / 60 / 60) % 30)
local Minutes = MF((Time / 60) % 60)
local Seconds = MF(Time % 60)
if Stop == 0 then
script.Parent.Time.Text = Days..":"..Hours.. ":"..Minutes..":"..Seconds.." "
end
if Days==0 and Hours==0 and Minutes==0 and Seconds==0 or Time < 0 then
Stop=0
script.Parent.Time.Text = "Rejoin!"
end
end