Trying to add Atmosphere onto Lighting Module

  1. What do you want to achieve? Editing a module that handles lighting to also incorporate new atmospheric lighting property into the day/night cycle

  2. Receiving this error

  3. Added onto tables and code and checked dev console, cant pinpoint error exactly.

local da={_LoadPriority=4,_Loaded=false,_Identity='circadian'}
local _b=game:GetService('TweenService')local ab=game:GetService('Lighting')
local bb=
ab:FindFirstChild('CircadianCorrection')or Instance.new('ColorCorrectionEffect',ab)local cb=1 /85
local db = ab:FindFirstChild('Atmosphere')
local function db(bc)local cc={}
for dc,_d in pairs(bc)do
local ad=TweenInfo.new(_d._EndTime-dc*cb,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
cc[dc]={_b:Create(ab,ad,_d.Lighting),_b:Create(bb,ad,_d.ColorCorrection),_b:Create(db,ad,_d.Atmosphere)}end;return cc end;local _c=nil
local function ac(bc)
return
{_EndTime=bc._EndTime.Value,Lighting={Ambient=bc.Lighting.Ambient.Value,OutdoorAmbient=bc.Lighting.OutdoorAmbient.Value,ColorShift_Top=bc.Lighting.ColorShift_Top.Value,ColorShift_Bottom=bc.Lighting.ColorShift_Bottom.Value,FogColor=bc.Lighting.FogColor.Value},Atmosphere = {Density=bc.Atmosphere.Density.Value,Offset = bc.Atmosphere.Offset.Value,Color = bc.Atmosphere.Color.Value,Decay = bc.Atmosphere.Decay.Value,Glare = bc.Atmosphere.Glare.Value,Haze = bc.Atmosphere.Haze.Value},ColorCorrection={Brightness=bc.ColorCorrection.Brightness.Value,Contrast=bc.ColorCorrection.Contrast.Value,Saturation=bc.ColorCorrection.Saturation.Value,TintColor=bc.ColorCorrection.TintColor.Value}}end
function da:Init(bc)
print(string.format('Initializing (%s)',self._Identity))
local cc={[4.5]={_EndTime=6.5,Lighting={Ambient=Color3.fromRGB(30,30,30),OutdoorAmbient=Color3.fromRGB(59,63,93)},Atmosphere={Density=0.395,Offset=0,Color=Color3.fromRGB(199,170,107),Decay=Color3.fromRGB(92,60,13),Glare=0,Haze=0},ColorCorrection={Brightness=
-0.06,Contrast=0,Saturation=-0.04,TintColor=Color3.fromRGB(213,213,245)}},[6.5]={_EndTime=7.5,Lighting={Ambient=Color3.fromRGB(47,47,47),OutdoorAmbient=Color3.fromRGB(102,84,113)},Atmosphere={Density=0.395,Offset=0,Color=Color3.fromRGB(199,170,107),Decay=Color3.fromRGB(92,60,13),Glare=0,Haze=0},ColorCorrection={Brightness=
-0.1,Contrast=0.01,Saturation=-0.02,TintColor=Color3.fromRGB(255,213,255)}},[7.5]={_EndTime=8.5,_Time=1,Lighting={Ambient=Color3.fromRGB(84,84,84),OutdoorAmbient=Color3.fromRGB(120,120,120)},Atmosphere={Density=0.395,Offset=0,Color=Color3.fromRGB(199,170,107),Decay=Color3.fromRGB(92,60,13),Glare=0,Haze=0},ColorCorrection={Brightness=
-0.06,Contrast=0.01,Saturation=0.02,TintColor=Color3.fromRGB(255,255,255)}},[17.5]={_EndTime=18.5,Lighting={Ambient=Color3.fromRGB(47,47,47),OutdoorAmbient=Color3.fromRGB(113,101,97)},Atmosphere={Density=0.395,Offset=0,Color=Color3.fromRGB(199,170,107),Decay=Color3.fromRGB(92,60,13),Glare=0,Haze=0},ColorCorrection={Brightness=
-0.06,Contrast=0.04,Saturation=0.09,TintColor=Color3.fromRGB(255,218,187)}},[18.5]={_EndTime=19.5,Lighting={Ambient=Color3.fromRGB(30,30,30),OutdoorAmbient=Color3.fromRGB(65,65,65)},Atmosphere={Density=0.395,Offset=0,Color=Color3.fromRGB(199,170,107),Decay=Color3.fromRGB(92,60,13),Glare=0,Haze=0},ColorCorrection={Brightness=
-0.07,Contrast=0,Saturation=-0.18,TintColor=Color3.fromRGB(140,156,173)}}}
if bb.Name=='CircadianCorrection'then for __a,a_a in pairs(cc)do
cc[__a]=ac(assert(game.Lighting:FindFirstChild('time - '..
__a..' to '..a_a._EndTime)))end end;local dc=(cb*tick())%24;ab.ClockTime=dc
do local __a=nil;local a_a=0;for b_a,c_a in pairs(cc)do
if(
__a==nil or b_a<=dc)and(a_a<=b_a)then __a=c_a;a_a=b_a end end
if a_a and cc[a_a]then for b_a,c_a in
pairs(cc[a_a].Lighting)do ab[b_a]=c_a end;for b_a,c_a in
pairs(cc[a_a].ColorCorrection)do bb[b_a]=c_a end end end;local _d=db(cc)cc=nil;local ad=false
local bd={clock=0.0,ambient=Color3.new(),outdoorAmbient=Color3.new(),runningTweens={}}local cd=Instance.new('ColorCorrectionEffect',ab)
cd.Brightness=0;cd.Contrast=0.1;cd.Enabled=ad;cd.Contrast=0.1;cd.Saturation=0.1
cd.TintColor=Color3.fromRGB(246,146,255)
bc.registerCommand({'stasis'},4,nil,"Command for disabling circadian",function(__a,a_a,b_a,c_a)if ad then return end;ad=true
bd.clock=ab.ClockTime;bd.ambient=ab.Ambient;bd.outdoorAmbient=ab.OutdoorAmbient
bd.runningTweens={}
for d_a,_aa in pairs(_d)do
for aaa,baa in pairs(_aa)do if baa.PlaybackState==Enum.PlaybackState.Playing then
table.insert(bd.runningTweens,baa)baa:Pause()end end end;bb.Enabled=not ad;cd.Enabled=ad;ab.ClockTime=12.0
ab.Ambient=Color3.fromRGB(35,35,35)ab.OutdoorAmbient=Color3.fromRGB(97,97,97)end)
bc.registerCommand({'mayhem'},4,nil,"Command for enabling circadian",function(__a,a_a,b_a,c_a)if not ad then return end;ad=false
ab.ClockTime=bd.clock;ab.Ambient=bd.ambient;ab.OutdoorAmbient=bd.outdoorAmbient;for d_a,_aa in
pairs(bd.runningTweens)do _aa:Play()end;bb.Enabled=not ad;cd.Enabled=ad end)local dd=0
spawn(function()
while wait(1)do
if not ad then dd=dc;dc=(cb*tick())%24;ab.ClockTime=dc;for __a,a_a in pairs(_d)do
if
__a>dd and __a<=dc then for b_a,c_a in pairs(a_a)do c_a:Play()end end end end end end)end;return da

Just going to put this out there even if this post gets flagged -

This code is not readable what-so-ever so please fix it! :slight_smile:

(Edit)
OK Iā€™m doing you a solid here if anyone wants the pretty(ish) code

local da = {
	_LoadPriority = 4,
	_Loaded = false,
	_Identity = 'circadian'
}
local _b = game:GetService('TweenService')
local ab = game:GetService('Lighting')
local bb =
ab:FindFirstChild('CircadianCorrection') or Instance.new('ColorCorrectionEffect', ab)
local cb = 1 / 85
local db = ab:FindFirstChild('Atmosphere')
local function db(bc)
	local cc = {}
	for dc, _d in pairs(bc) do
		local ad = TweenInfo.new(_d._EndTime - dc * cb, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
		cc[dc] = {
			_b:Create(ab, ad, _d.Lighting),
			_b:Create(bb, ad, _d.ColorCorrection),
			_b:Create(db, ad, _d.Atmosphere)
		}
	end;
	return cc
end;
local _c = nil
local function ac(bc)
	return
{
		_EndTime = bc._EndTime.Value,
		Lighting = {
			Ambient = bc.Lighting.Ambient.Value,
			OutdoorAmbient = bc.Lighting.OutdoorAmbient.Value,
			ColorShift_Top = bc.Lighting.ColorShift_Top.Value,
			ColorShift_Bottom = bc.Lighting.ColorShift_Bottom.Value,
			FogColor = bc.Lighting.FogColor.Value
		},
		Atmosphere = {
			Density = bc.Atmosphere.Density.Value,
			Offset = bc.Atmosphere.Offset.Value,
			Color = bc.Atmosphere.Color.Value,
			Decay = bc.Atmosphere.Decay.Value,
			Glare = bc.Atmosphere.Glare.Value,
			Haze = bc.Atmosphere.Haze.Value
		},
		ColorCorrection = {
			Brightness = bc.ColorCorrection.Brightness.Value,
			Contrast = bc.ColorCorrection.Contrast.Value,
			Saturation = bc.ColorCorrection.Saturation.Value,
			TintColor = bc.ColorCorrection.TintColor.Value
		}
	}
end
function da:Init(bc)
	print(string.format('Initializing (%s)', self._Identity))
	local cc = {
		[4.5] = {
			_EndTime = 6.5,
			Lighting = {
				Ambient = Color3.fromRGB(30, 30, 30),
				OutdoorAmbient = Color3.fromRGB(59, 63, 93)
			},
			Atmosphere = {
				Density = 0.395,
				Offset = 0,
				Color = Color3.fromRGB(199, 170, 107),
				Decay = Color3.fromRGB(92, 60, 13),
				Glare = 0,
				Haze = 0
			},
			ColorCorrection = {
				Brightness =
-0.06,
				Contrast = 0,
				Saturation = -0.04,
				TintColor = Color3.fromRGB(213, 213, 245)
			}
		},
		[6.5] = {
			_EndTime = 7.5,
			Lighting = {
				Ambient = Color3.fromRGB(47, 47, 47),
				OutdoorAmbient = Color3.fromRGB(102, 84, 113)
			},
			Atmosphere = {
				Density = 0.395,
				Offset = 0,
				Color = Color3.fromRGB(199, 170, 107),
				Decay = Color3.fromRGB(92, 60, 13),
				Glare = 0,
				Haze = 0
			},
			ColorCorrection = {
				Brightness =
-0.1,
				Contrast = 0.01,
				Saturation = -0.02,
				TintColor = Color3.fromRGB(255, 213, 255)
			}
		},
		[7.5] = {
			_EndTime = 8.5,
			_Time = 1,
			Lighting = {
				Ambient = Color3.fromRGB(84, 84, 84),
				OutdoorAmbient = Color3.fromRGB(120, 120, 120)
			},
			Atmosphere = {
				Density = 0.395,
				Offset = 0,
				Color = Color3.fromRGB(199, 170, 107),
				Decay = Color3.fromRGB(92, 60, 13),
				Glare = 0,
				Haze = 0
			},
			ColorCorrection = {
				Brightness =
-0.06,
				Contrast = 0.01,
				Saturation = 0.02,
				TintColor = Color3.fromRGB(255, 255, 255)
			}
		},
		[17.5] = {
			_EndTime = 18.5,
			Lighting = {
				Ambient = Color3.fromRGB(47, 47, 47),
				OutdoorAmbient = Color3.fromRGB(113, 101, 97)
			},
			Atmosphere = {
				Density = 0.395,
				Offset = 0,
				Color = Color3.fromRGB(199, 170, 107),
				Decay = Color3.fromRGB(92, 60, 13),
				Glare = 0,
				Haze = 0
			},
			ColorCorrection = {
				Brightness =
-0.06,
				Contrast = 0.04,
				Saturation = 0.09,
				TintColor = Color3.fromRGB(255, 218, 187)
			}
		},
		[18.5] = {
			_EndTime = 19.5,
			Lighting = {
				Ambient = Color3.fromRGB(30, 30, 30),
				OutdoorAmbient = Color3.fromRGB(65, 65, 65)
			},
			Atmosphere = {
				Density = 0.395,
				Offset = 0,
				Color = Color3.fromRGB(199, 170, 107),
				Decay = Color3.fromRGB(92, 60, 13),
				Glare = 0,
				Haze = 0
			},
			ColorCorrection = {
				Brightness =
-0.07,
				Contrast = 0,
				Saturation = -0.18,
				TintColor = Color3.fromRGB(140, 156, 173)
			}
		}
	}
	if bb.Name == 'CircadianCorrection' then
		for __a, a_a in pairs(cc) do
			cc[__a] = ac(assert(game.Lighting:FindFirstChild('time - '..
__a..' to '..a_a._EndTime)))
		end
	end;
	local dc = (cb * tick()) % 24;
	ab.ClockTime = dc
	do
		local __a = nil;
		local a_a = 0;
		for b_a, c_a in pairs(cc) do
			if (
__a == nil or b_a <= dc) and (a_a <= b_a) then
				__a = c_a;
				a_a = b_a
			end
		end
		if a_a and cc[a_a] then
			for b_a, c_a in
pairs(cc[a_a].Lighting) do
				ab[b_a] = c_a
			end;
			for b_a, c_a in
pairs(cc[a_a].ColorCorrection) do
				bb[b_a] = c_a
			end
		end
	end;
	local _d = db(cc)
	cc = nil;
	local ad = false
	local bd = {
		clock = 0.0,
		ambient = Color3.new(),
		outdoorAmbient = Color3.new(),
		runningTweens = {}
	}
	local cd = Instance.new('ColorCorrectionEffect', ab)
	cd.Brightness = 0;
	cd.Contrast = 0.1;
	cd.Enabled = ad;
	cd.Contrast = 0.1;
	cd.Saturation = 0.1
	cd.TintColor = Color3.fromRGB(246, 146, 255)
	bc.registerCommand({
		'stasis'
	}, 4, nil, "Command for disabling circadian", function(__a, a_a, b_a, c_a)
		if ad then
			return
		end;
		ad = true
		bd.clock = ab.ClockTime;
		bd.ambient = ab.Ambient;
		bd.outdoorAmbient = ab.OutdoorAmbient
		bd.runningTweens = {}
		for d_a, _aa in pairs(_d) do
			for aaa, baa in pairs(_aa) do
				if baa.PlaybackState == Enum.PlaybackState.Playing then
					table.insert(bd.runningTweens, baa)
					baa:Pause()
				end
			end
		end;
		bb.Enabled = not ad;
		cd.Enabled = ad;
		ab.ClockTime = 12.0
		ab.Ambient = Color3.fromRGB(35, 35, 35)
		ab.OutdoorAmbient = Color3.fromRGB(97, 97, 97)
	end)
	bc.registerCommand({
		'mayhem'
	}, 4, nil, "Command for enabling circadian", function(__a, a_a, b_a, c_a)
		if not ad then
			return
		end;
		ad = false
		ab.ClockTime = bd.clock;
		ab.Ambient = bd.ambient;
		ab.OutdoorAmbient = bd.outdoorAmbient;
		for d_a, _aa in
pairs(bd.runningTweens) do
			_aa:Play()
		end;
		bb.Enabled = not ad;
		cd.Enabled = ad
	end)
	local dd = 0
	spawn(function()
		while wait(1) do
			if not ad then
				dd = dc;
				dc = (cb * tick()) % 24;
				ab.ClockTime = dc;
				for __a, a_a in pairs(_d) do
					if
__a > dd and __a <= dc then
						for b_a, c_a in pairs(a_a) do
							c_a:Play()
						end
					end
				end
			end
		end
	end)
end;
return da
2 Likes