Hiya, so this is meant to detect when the game time is 6pm, make a gui frame visible, and start a timer.
It doesn’t seem to be working, if you could help that would be great.
local timer = script.Parent.Timer
while true do
wait(0.1)
if game.lighting:GetMinutesAfterMidnight() > 6 * 60 then
timer.Parent.Visible = true
timer.Text = ("10")
wait(1)
timer.Text = ("9")
wait(1)
timer.Text = ("8")
wait(1)
timer.Text = ("7")
wait(1)
timer.Text = ("6")
wait(1)
timer.Text = ("5")
wait(1)
timer.Text = ("4")
wait(1)
timer.Text = ("3")
wait(1)
timer.Text = ("2")
wait(1)
timer.Text = ("1")
wait(1)
script.Parent.Visible = false
end
if game.Lighting:GetMinutesAfterMidnight() > 18 * 60 then
end
end
for i = minNumber, maxNumber, increment do
-- // Following code will run every loop.
wait(1) -- // Amount of time between each loop, if minNumber == maxNumber then the loop stops.
end
Edit: This comment wasn’t supposed to be a solution rather a tip.
There is a problem where the first if statement is executed every time(10 + 0.1 + time inaccuracies) after 6 AM. As of now, if it passes 18:00, it will execute both blocks, that time added with the new block’s time to cycle.
Also why is it game.lighting and not game.Lighting? A better alternative is game:GetService("Lighting").
You wouldn’t use a while true do loop in this case. Apparently listening in for events would help a lot to not hog up the memory.
local timer = script.Parent.Timer
local countdown = false
while wait(.1) do
if game.Lighting.ClockTime > 6 and game.Lighting.ClockTime < 9 and countdown == false then -- 9 = range of time
countdown = true
timer.Visible = true
for i=1,10 do
wait(1)
timer.Text = tostring(11-i)
end
script.Parent.Visible = false -- dunno if this should be timer.Parent.Visible = false or if this is intended
countdown = false
-- If you don't want it to repeat again at 6 o'clock have it wait until the clock time is different with this:
if game.Lighting.ClockTime > 9 then -- also range of time
countdown = false -- if you are going with this method, remove the other countdown = false directly above here
end
end
end
Sorry it isn’t more organized I don’t know the replacement for tab in the dev forum.