What I'd like to do is have a GUI tween onto the screen when a certain time of night hits, but I have no earthly idea how to do that. All that I need is something that just activates it when a "Sky" object hits, like, midnight.
✓ ANSWER ACCEPTED
Is there any possible way to have a GUI tween onto the screen once night falls?
1 answer
✓ Accepted answer
Nothings impossible. To do this let's use the event LightingChanged of lighting + GetMinutesAfterMidnight() function to check
game.Lighting.LightingChanged:connect(function(skyboxchanged)
end)
Next let's check that it wasn't skybox that changed
game.Lighting.LightingChanged:connect(function(skyboxchanged)
if skyboxchanged==false then
end
end)
Also let's create a tween function + a check function with a bounce This will make it so that the tween function will only run once when it enters night
function tween()
--stuff
end
local init = false
local last = init
function check()
if init==true and last~=init then
tween()
end
last=init
end
Now to check what time it is
game.Lighting.LightingChanged:connect(function(skyboxchanged)
if skyboxchanged==false then
if (game.Lighting:GetMinutesAfterMidnight()>1200 and game.Lighting:GetMinutesAfterMidnight()<1439) or (game.Lighting:GetMinutesAfterMidnight()<300 and game.Lighting:GetMinutesAfterMidnight()>0) then
init=true
check()
else
init=false
check()
end
end
end)
This will check if the time in when its dark and if so it'll change init to true and fire the check function who will then check if its only once which it enters night and then fire tween
Let's put it together,
function tween()
--stuff
end
local init = false
local last = init
function check()
if init==true and last~=init then
tween()
end
last=init
end
game.Lighting.LightingChanged:connect(function(skyboxchanged)
if skyboxchanged==false then
if (game.Lighting:GetMinutesAfterMidnight()>1200 and game.Lighting:GetMinutesAfterMidnight()<1439) or (game.Lighting:GetMinutesAfterMidnight()<300 and game.Lighting:GetMinutesAfterMidnight()>0) then
init=true
check()
else
init=false
check()
end
end
end)
And here's it together with a tween function in the tween function (lol)
local gui = script.Parent
function tween()
gui:Tween(stuff)
end
local init = false
local last = init
function check()
if init==true and last~=init then
tween()
end
last=init
end
game.Lighting.LightingChanged:connect(function(skyboxchanged)
if skyboxchanged==false then
if (game.Lighting:GetMinutesAfterMidnight()>1200 and game.Lighting:GetMinutesAfterMidnight()<1439) or (game.Lighting:GetMinutesAfterMidnight()<300 and game.Lighting:GetMinutesAfterMidnight()>0) then
init=true
check()
else
init=false
check()
end
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Now would this go inside the gui itself or would it go into workspace?
@Auto2359 A localscript, then point the variable 'gui' towards your gui and add you args to the tween function