I have this script lying around, I’ve used it for awhile now. But I really want to make the script more organized and easy to read. (An old script made by me.)
local tweenSerivce = game:GetService("TweenService")
local dayLighting = script.dayLighting
local nightLighting = script.nightLighting
local lighting = game:GetService("Lighting")
local atmos = lighting:FindFirstChild("atmos")
local bloom = lighting:FindFirstChild("bloom")
local colorCorrection = lighting:FindFirstChild("colorCorrection")
local DoF = lighting:FindFirstChild("dof")
local sunRays = lighting:FindFirstChild("sunRays")
if not atmos and not bloom and not colorCorrection and not DoF and not sunRays then
warn("All Children are missing! Creating new ones...")
local newAtmos = Instance.new("Atmosphere")
newAtmos.Name = "atmos"
newAtmos.Parent = lighting
newAtmos.Density = dayLighting.atmosDensity.Value
newAtmos.Offset = dayLighting.atmosOffset.Value
newAtmos.Color = dayLighting.atmosColor.Value
newAtmos.Decay = dayLighting.atmosDecay.Value
newAtmos.Glare = dayLighting.atmosGlare.Value
newAtmos.Haze = dayLighting.atmosHaze.Value
local newBloom = Instance.new("BloomEffect")
newBloom.Name = "bloom"
newBloom.Parent = lighting
newBloom.Size = dayLighting.bloomSize.Value
newBloom.Intensity = dayLighting.bloomInstensity.Value
newBloom.Threshold = dayLighting.bloomThreshold.Value
local newColorCorrection = Instance.new("ColorCorrectionEffect")
newColorCorrection.Name = "colorCorrection"
newColorCorrection.Parent = lighting
newColorCorrection.Brightness = dayLighting.ccBrightness.Value
newColorCorrection.Contrast = dayLighting.ccContrast.Value
newColorCorrection.Saturation = dayLighting.ccSaturation.Value
newColorCorrection.TintColor = dayLighting.ccTint.Value
local newDoF = Instance.new("DepthOfFieldEffect")
newDoF.Name = "dof"
newDoF.Parent = lighting
newDoF.FarIntensity = dayLighting.dofFarIntensity.Value
newDoF.FocusDistance = dayLighting.dofFocusDistance.Value
newDoF.InFocusRadius = dayLighting.dofInFocusRadius.Value
newDoF.NearIntensity = dayLighting.dofNearIntensity.Value
local newSunRays = Instance.new("SunRaysEffect")
newSunRays.Name = "sunRays"
newSunRays.Parent = lighting
newSunRays.Intensity = dayLighting.srIntensity.Value
newSunRays.Spread = dayLighting.srSpread.Value
atmos=newAtmos;
bloom=newBloom;
colorCorrection=newColorCorrection;
DoF=newDoF;
sunRays=newSunRays;
end
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local dayTweens = {
["Atmos"] = tweenSerivce:Create(atmos, tweenInfo, {
Density = dayLighting.atmosDensity.Value,
Offset = dayLighting.atmosOffset.Value,
Color = dayLighting.atmosColor.Value,
Decay = dayLighting.atmosDecay.Value,
Glare = dayLighting.atmosGlare.Value,
Haze = dayLighting.atmosHaze.Value
}),
["Bloom"] = tweenSerivce:Create(bloom, tweenInfo, {
Intensity = dayLighting.bloomInstensity.Value,
Size = dayLighting.bloomSize.Value,
Threshold = dayLighting.bloomThreshold.Value
}),
["colorCorrection"] = tweenSerivce:Create(colorCorrection, tweenInfo, {
Brightness = dayLighting.ccBrightness.Value,
Contrast = dayLighting.ccContrast.Value,
Saturation = dayLighting.ccSaturation.Value,
TintColor = dayLighting.ccTint.Value
}),
["DoF"] = tweenSerivce:Create(DoF, tweenInfo, {
FarIntensity = dayLighting.dofFarIntensity.Value,
FocusDistance = dayLighting.dofFocusDistance.Value,
InFocusRadius = dayLighting.dofInFocusRadius.Value,
NearIntensity = dayLighting.dofNearIntensity.Value
}),
["sunRays"] = tweenSerivce:Create(sunRays, tweenInfo, {
Intensity = dayLighting.srIntensity.Value,
Spread = dayLighting.srSpread.Value
}),
}
local nightTweens = {
["Atmos"] = tweenSerivce:Create(atmos, tweenInfo, {
Density = nightLighting.atmosDensity.Value,
Offset = nightLighting.atmosOffset.Value,
Color = nightLighting.atmosColor.Value,
Decay = nightLighting.atmosDecay.Value,
Glare = nightLighting.atmosGlare.Value,
Haze = nightLighting.atmosHaze.Value
}),
["Bloom"] = tweenSerivce:Create(bloom, tweenInfo, {
Intensity = nightLighting.bloomInstensity.Value,
Size = nightLighting.bloomSize.Value,
Threshold = nightLighting.bloomThreshold.Value
}),
["colorCorrection"] = tweenSerivce:Create(colorCorrection, tweenInfo, {
Brightness = nightLighting.ccBrightness.Value,
Contrast = nightLighting.ccContrast.Value,
Saturation = nightLighting.ccSaturation.Value,
TintColor = nightLighting.ccTint.Value
}),
["DoF"] = tweenSerivce:Create(DoF, tweenInfo, {
FarIntensity = nightLighting.dofFarIntensity.Value,
FocusDistance = nightLighting.dofFocusDistance.Value,
InFocusRadius = nightLighting.dofInFocusRadius.Value,
NearIntensity = nightLighting.dofNearIntensity.Value
}),
["sunRays"] = tweenSerivce:Create(sunRays, tweenInfo, {
Intensity = nightLighting.srIntensity.Value,
Spread = nightLighting.srSpread.Value
}),
}
lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
if lighting.ClockTime > 18 or lighting.ClockTime < 6 then
nightTweens.Atmos:Play()
nightTweens.Bloom:Play()
nightTweens.colorCorrection:Play()
nightTweens.DoF:Play()
nightTweens.sunRays:Play()
elseif lighting.ClockTime < 18 or lighting.ClockTime > 6 then
dayTweens.Atmos:Play()
dayTweens.Bloom:Play()
dayTweens.colorCorrection:Play()
dayTweens.DoF:Play()
dayTweens.sunRays:Play()
end
end)
This script uses a folder of the lighting objects’ properties.
Any help would be appreciated :d