Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to change Lightning settings?

Asked by 9 years ago

Everything works fine but after "Back Normal" Everything is just white when i toke the lightning before it changes. I mean when i change it is white when default you see normal colors. (Test it out) Whats wrong?

01local A = "event1"
02local Time = game.Lighting --Time
03local Br = game.Lighting --Brightness
04local OA = game.Lighting --OutdoorAmbient
05local SC = game.Lighting --ShadowColor
06local fogC = game.Lighting --FogColor
07local FoEnd = game.Lighting --FogEnd
08local FoSt = game.Lighting --FogStart
09 
10game.Players.PlayerAdded:wait()
11 
12while true do
13    wait (20)
14    game.Lighting:findFirstChild(A):clone().Parent = game.Workspace
15    Time.TimeOfDay = "00:00:00"
View all 31 lines...

1 answer

Log in to vote
2
Answered by 9 years ago

What you're doing incorrectly is creating the Color3 values.

01local A = "event1"
02local Lighting = game.Lighting
03 
04game.Players.PlayerAdded:wait()
05 
06while true do
07    wait (2)
08    Lighting:FindFirstChild(A):Clone().Parent = game.Workspace
09    Lighting.TimeOfDay = "00:00:00"
10    Lighting.Ambient = Color3.new(0, 0, 0)
11    Lighting.Brightness = 0.001
12    Lighting.ColorShift_Bottom = Color3.new(0, 0, 0)
13    Lighting.ColorShift_Top = Color3.new(0, 0, 0)
14    Lighting.OutdoorAmbient = Color3.new(0, 0, 0)
15    Lighting.ShadowColor = Color3.new(0, 0, 0)
View all 31 lines...

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:

1game.Lighting:findFirstChild(A):clone().Parent = game.Workspace

to this:

1Lighting: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

1game.Workspace:findFirstChild(A):remove()

to this, which doesn't have deprecated functions:

1game.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:

01local A = "event1"
02local Lighting = game.Lighting
03 
04game.Players.PlayerAdded:wait()
05 
06local initialLighting = {
07    TimeOfDay = "12:00:00",
08    Ambient = Color3.new(0, 0, 0),
09    Brightness = 1,
10    ColorShift_Bottom = Color3.new(0, 0, 0),
11    ColorShift_Top = Color3.new(0, 0, 0),
12    OutdoorAmbient = Color3.new(127/255, 127/255, 127/255),
13    ShadowColor = Color3.new(178/255, 178/255, 183/255),
14    FogColor = Color3.new(191/255, 191/255, 191/255),
15    FogEnd = 100000,
View all 44 lines...

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!

0
You might as well just do `Lighting[A]:Clone()` BlueTaslem 18071 — 9y
0
Thank you so much! minetrackmania 186 — 9y
0
@BlueTaslem Yeah, I suppose. But perhaps not. I have no idea of what sort of environment he's dealing with. :P Programmix 285 — 9y
Ad

Answer this question