Need help with the Atmosphere module day & night cycle

  1. What do you want to achieve? I want to create a script where the Atmospheric Lighting changes as the day & night cycle go on

  2. What is the issue? I can’t seem to figure it out and can’t find any tutorials or help on this subject.

  3. What solutions have you tried so far? I looked everywhere to no avail.

Im looking for anyone to help me on this subject, maybe suggest where I can find answers to my problem, i would really appreciate it!
This is the current lighting system that I have.

 local minPerSec = 60; --How many minutes pass every real life second
--Set the above to 1/60 for real time
local lighting = game:GetService('Lighting')
local lastTick = tick()
local pi = math.pi
while true do
   local cur = lighting:GetMinutesAfterMidnight()
   cur = cur + (minPerSec*(tick()-lastTick))
   lighting:SetMinutesAfterMidnight(cur)
   lastTick = tick()
   wait()
end

--brightness
local amplitudeB = 1
local offsetB = 2

--outdoor ambieant
local var
local amplitudeO = 20
local offsetO = 100

--shadow softness
local amplitudeS = .2
local offsetS = .8

--astmosphere


--color shift top
local pointer
                 -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
local rColorList = {000,000,000,000,000,255,255,255,255,255,255,255,255,255,255,255,255,255,255,000,000,000,000,000}
local gColorList = {165,165,165,165,165,255,215,230,255,255,255,255,255,255,255,245,230,215,255,165,165,165,165,165}
local bColorList = {255,255,255,255,255,255,110,135,255,255,255,255,255,255,255,215,135,110,255,255,255,255,255,255}
local r
local g
local b

while true do
     --brightness
     game.Lighting.Brightness = amplitudeB*math.cos(lastTick*(pi/12)+pi)+offsetB

     --outdoor ambient
     var=amplitudeO*math.cos(lastTick*(pi/12)+pi)+offsetO
     game.Lighting.OutdoorAmbient = Color3.fromRGB(var,var,var)

     --shadow softness
     game.Lighting.ShadowSoftness = amplitudeS*math.cos(lastTick*(pi/6))+offsetS

     --color shift top
     pointer= math.ceil(lastTick)
     r=((rColorList[pointer%24+1]-rColorList[pointer])*(lastTick-pointer+1))+rColorList[pointer]
     g=((gColorList[pointer%24+1]-gColorList[pointer])*(lastTick-pointer+1))+gColorList[pointer]
     b=((bColorList[pointer%24+1]-bColorList[pointer])*(lastTick-pointer+1))+bColorList[pointer]
     game.Lighting.ColorShift_Top=Color3.fromRGB(r,g,b)

     --tick
     wait()
end
1 Like

I’m unsure what this is even meant to do.
Why do you store so many color values (rColorList, gColorList, …)?

1 Like

Those colour values help change the ‘color shift top’ during the day and night, so when it gets noon the color changes a bit so it looks more natural and cinematic.

1 Like

id just add a modifier to the current game time, that way as the time changes so will the ambient. May need two sort of sections, one for am one for pm

1 Like

I would assume so, but I am not sure how to script that, so I am looking where I can find some help on this. I am a beginner in programming, sorry.

1 Like