Celestial Objects on the same side of the sky

  1. What do you want to achieve? Keep it simple and clear!
    I tried to make a module script which would change the lighting to preset templates, listed inside a module.

Code:

local Background = {}

local LIGHTING = game:GetService("Lighting")
local Utilities = require(script.Parent.Utilities)
local Create = Utilities.Create -- create is a function that makes Instance.new() formatting neater
local PRESET,MODES,DISABLED = {},{},{Enabled = false}

local ORDER = {LIGHTING, "Bloom", "Blur", "ColorCorrection", "SunRays"}

function Background:Set(Name)
	for k,v in pairs(PRESET[Name]) do
		local Effect = (ORDER[k] == LIGHTING and LIGHTING) or (LIGHTING:FindFirstChild(ORDER[k]) or Instance.new(ORDER[k].."Effect",LIGHTING))
		for K,V in pairs(v) do
			Effect[K] = V
		end
	end
end

function Background:Mode(Name)
	Create(unpack(MODES[Name]))
end

function Background:CancelMode(Name)
	LIGHTING:FindFirstChild(Name):Destroy()
end

MODES = {
	Flashback = {"ColorCorrectionEffect",{
		Parent = LIGHTING,
		TintColor = Color3.fromRGB(225,176,155),
		Name = "Flashback",
		Saturation = -.5,
		Brightness = -.04,
		Contrast = -.2
		}}
}

PRESET = {
	
	Morning =	{
					{
						Ambient = Color3.fromRGB(67,63,36),
						Brightness = 1,
						ColorShift_Bottom = Color3.fromRGB(255,248,161),
						ColorShift_Top = Color3.fromRGB(255,248,161),
						OutdoorAmbient = Color3.fromRGB(255,191,112),
						TimeOfDay = "07:00:00",
						GeographicLatitude = 95,
						FogColor = Color3.fromRGB(232,232,232),
						FogEnd = 10000000
					},
					DISABLED,
					DISABLED,
					{
						Brightness = 0,
						Contrast = .1,
						Saturation = .1,
						TintColor = Color3.fromRGB(255,242,221)
					},
					DISABLED
				},
	
	Midday = {
				{
					Ambient = Color3.fromRGB(67,63,36),
					Brightness = 1,
					ColorShift_Bottom = Color3.fromRGB(255,255,255),
					ColorShift_Top = Color3.fromRGB(255,255,255),
					OutdoorAmbient = Color3.fromRGB(255,191,112),
					TimeOfDay = "12:00:00",
					GeographicLatitude = 95,
					FogColor = Color3.fromRGB(232,232,232),
					FogEnd = 10000000
				},
				DISABLED,
				DISABLED,
				{
					Brightness = .06,
					Contrast = .01,
					Saturation = 0,
					TintColor = Color3.fromRGB(255,255,255)
				},
				DISABLED
			},
	
	Evening = {
				{
					Ambient = Color3.fromRGB(67,63,36),
					Brightness = 1,
					ColorShift_Bottom = Color3.fromRGB(255,248,161),
					ColorShift_Top = Color3.fromRGB(255,248,161),
					OutdoorAmbient = Color3.fromRGB(255,191,112),
					TimeOfDay = "17:45:00",
					GeographicLatitude = 95,
					FogColor = Color3.fromRGB(232,232,232),
					FogEnd = 10000000
				},
				DISABLED,
				DISABLED,
				{
					Brightness = .06,
					Contrast = .01,
					Saturation = 0,
					TintColor = Color3.fromRGB(255,255,255)
				},
				DISABLED
			},

	Night = {
					{
						Ambient = Color3.fromRGB(67,63,36),
						Brightness = 1,
						ColorShift_Bottom = Color3.fromRGB(240,233,146),
						ColorShift_Top = Color3.fromRGB(240,233,146),
						OutdoorAmbient = Color3.fromRGB(245,181,102),
						TimeOfDay = "19:00:00",
						GeographicLatitude = 95,
						FogColor = Color3.fromRGB(232,232,232),
						FogEnd = 10000000
					},
					DISABLED,
					DISABLED,
					{
						Brightness = -.04,
						Contrast = .1,
						Saturation = .1,
						TintColor = Color3.fromRGB(255,236,213)
					},
					DISABLED
				},
		
	Midnight = {
				{
					Ambient = Color3.fromRGB(200,200,200),
					Brightness = .8,
					TimeOfDay = "05:00:00"
				},
				DISABLED,
				DISABLED,
				{	
					Brightness = .02,
					Contrast = .06,
					TintColor = Color3.new(1,1,1),
					Enabled = true,
					Saturation = .18
				},
				{	
					Enabled = true,
					Intensity = .15,
					Spread = 1
				}	
			},
	
}
return Background

Server code:
require(game.ReplicatedStorage.Light):Set("Evening")

  1. What is the issue? Include screenshots / videos if possible!
    When I tried to run the script, the sun and the moon appear on the same side.

    sun1 moon1

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I didn’t find anyone else encountering the same problem, and the hub didn’t offer solutions either. I have also tried to run the script on the client, but the same thing happens.

1 Like

Can you please format your code, it’ll be easier to read and make people more willing to help.

1 Like