I need a script so I can make a day and night sequence and when it gets darker the camera gets darker as well so can anyone give me the script?
Day And Night?
2 answers
Lighting = game.Lighting -- I've set a static variable to the Lighting service.
while true do -- A 'while' loop is used to continuously execute this code block.
local Time = Lighting:GetMinutesAfterMidnight() -- A local variable is used to refer to the amount of minutes after midnight.
Lighting:SetMinutesAfterMidnight(Time + 1) -- I've added 1 minute to the amount of minutes after midnight.
wait(.1) -- A 'wait' is needed in a 'while' loop.
end
The :GetMinutesAfterMidnight method returns a number that tells you the amount of minutes after midnight.
If the 'TimeOfDay' property is set to "16:00:00", then
print(game.Lighting:GetMinutesAfterMidnight())
it will return '960' in the output (as in 960 minutes).
The :SetMinutesAfterMidnight method accepts a number and utilizes it to literally set the minutes after midnight.
game.Lighting:SetMinutesAfterMidnight(840)
print(game.Lighting.TimeOfDay)
The 'TimeOfDay' will return '14:00:00'.
A 'while' loop executes the code continuously.
A static variable is another name for a global variable. It can be accessed from anywhere (in a function, in a 'while' loop, etc).
A local variable can only be accessed in the code block it is in and in that code block only.
EXAMPLE
A = "This is from a static variable"
function Example()
print(A)
local A = "This is from a LOCAL variable"
print(A)
end
print(A)
Example()
print(A)
OUTPUT:
This is from a static variable -- From line 9
This is from a static variable -- From line 4
This is from a LOCAL variable -- From line 6
This is from a static variable -- From line 13
local R=true
function Time()
for i=0,24,1 do
R=false
wait(1)
game.Lighting.TimeOfDay=i
end
R=true
end
while wait(0.1) do
if R==true then
Time()
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
im new to scripting so yea
Since this is your first post I will give you the script BUT next time try to make your own script before posting. THIS IS NOT A REQUEST SITE!