What you're doing incorrectly is creating the Color3 values.
02 | local Lighting = game.Lighting |
04 | game.Players.PlayerAdded:wait() |
08 | Lighting:FindFirstChild(A):Clone().Parent = game.Workspace |
09 | Lighting.TimeOfDay = "00:00:00" |
10 | Lighting.Ambient = Color 3. new( 0 , 0 , 0 ) |
11 | Lighting.Brightness = 0.001 |
12 | Lighting.ColorShift_Bottom = Color 3. new( 0 , 0 , 0 ) |
13 | Lighting.ColorShift_Top = Color 3. new( 0 , 0 , 0 ) |
14 | Lighting.OutdoorAmbient = Color 3. new( 0 , 0 , 0 ) |
15 | Lighting.ShadowColor = Color 3. new( 0 , 0 , 0 ) |
16 | Lighting.FogColor = Color 3. new( 0 , 0 , 0 ) |
20 | Lighting.TimeOfDay = "12:00:00" |
21 | Lighting.Ambient = Color 3. new( 0 , 0 , 0 ) |
22 | Lighting.Brightness = 1 |
23 | Lighting.ColorShift_Bottom = Color 3. new( 0 , 0 , 0 ) |
24 | Lighting.ColorShift_Top = Color 3. new( 0 , 0 , 0 ) |
25 | Lighting.OutdoorAmbient = Color 3. new( 127 / 255 , 127 / 255 , 127 / 255 ) |
26 | Lighting.ShadowColor = Color 3. new( 178 / 255 , 178 / 255 , 183 / 255 ) |
27 | Lighting.FogColor = Color 3. new( 191 / 255 , 191 / 255 , 191 / 255 ) |
28 | Lighting.FogEnd = 100000 |
30 | game.Workspace:FindFirstChild(A):Destroy() |
Here's a rundown of what changed:
Firstly, I changed all of those variable names that referenced game.Lighting to one variable: Lighting. All of those variables weren't necessary, and lessened the readability of the script.
Next, I changed the first line of the while loop, which was:
1 | game.Lighting:findFirstChild(A):clone().Parent = game.Workspace |
to this:
1 | Lighting:FindFirstChild(A):Clone().Parent = game.Workspace |
Firstly, I changed the variable that's being referenced to "Lighting", instead of game.Lighting, since we already have a variable for Lighting.
It also now uses "FindFirstChild", not "findFirstChild" (notice the case difference) since "findFirstChild" is deprecated, as well as "Clone" instead of "clone", since "clone" is also deprecated.
The main thing that I changed is the Color3.new lines in the second part of the code. You were creating Color3 values with raw numbers. The Color3 library actually takes colors as a decimal out of 1. So, you have to divide the values you want by 255 in order to get the desired result.
I changed this line
1 | game.Workspace:findFirstChild(A):remove() |
to this, which doesn't have deprecated functions:
1 | game.Workspace:FindFirstChild(A):Destroy() |
Lastly, if you want to get really advanced with how you're doing this, I'd suggest the following solution as a more easily configurable alternative:
02 | local Lighting = game.Lighting |
04 | game.Players.PlayerAdded:wait() |
06 | local initialLighting = { |
07 | TimeOfDay = "12:00:00" , |
08 | Ambient = Color 3. new( 0 , 0 , 0 ), |
10 | ColorShift_Bottom = Color 3. new( 0 , 0 , 0 ), |
11 | ColorShift_Top = Color 3. new( 0 , 0 , 0 ), |
12 | OutdoorAmbient = Color 3. new( 127 / 255 , 127 / 255 , 127 / 255 ), |
13 | ShadowColor = Color 3. new( 178 / 255 , 178 / 255 , 183 / 255 ), |
14 | FogColor = Color 3. new( 191 / 255 , 191 / 255 , 191 / 255 ), |
19 | local darkerLighting = { |
20 | TimeOfDay = "00:00:00" , |
21 | Ambient = Color 3. new( 0 , 0 , 0 ), |
23 | ColorShift_Bottom = Color 3. new( 0 , 0 , 0 ), |
24 | ColorShift_Top = Color 3. new( 0 , 0 , 0 ), |
25 | OutdoorAmbient = Color 3. new( 0 , 0 , 0 ), |
26 | ShadowColor = Color 3. new( 0 , 0 , 0 ), |
27 | FogColor = Color 3. new( 0 , 0 , 0 ), |
35 | Lighting:FindFirstChild(A):Clone().Parent = game.Workspace |
36 | for property, value in pairs (darkerLighting) do |
37 | Lighting [ property ] = value |
40 | for property, value in pairs (initialLighting) do |
41 | Lighting [ property ] = value |
43 | game.Workspace:FindFirstChild(A):Destroy() |
Essentially, what this does is create two tables of various states of Lighting, using a key-value format that represents a property and its value. When the time comes to set the Lighting properties to various values, a for loop iterates through all of the properties and their values, assigning the property to its corresponding value in Lighting.
Hope this helps. Good luck!