Script Doesnt Change Parents Or Lighting Values?
Asked by
2 years ago Edited 2 years ago
This is based on my old post, this time I made the code a bit simpler (not really) and tried to explain the problems more clearly, sorry for the inconvenience
I'm making a script so that whenever the value changes, it will get the current lighting children and move them back into a folder in ReplicatedStorage (or for the first time, sets the parent to nil) and gets the children from another folder in ReplicatedStorage and sets their parents to lighting, while also changing some of the settings in lighting, but for some reason, the script doesn't change the parents or changes some of the lighting settings, if anyone can help, I would appreciate it
01 | local Lighting = game:GetService( "Lighting" ) |
02 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
03 | local lobby = ReplicatedStorage.Lobby:GetChildren() |
04 | local abandonedoffice = ReplicatedStorage.AbandonedOffice:GetChildren() |
05 | local LightingChildren = Lighting:GetChildren() |
06 | local curlev = workspace [ "CurLevel" ] |
08 | local function setParent(children, parent) |
09 | for _, child in ipairs (children) do |
14 | curlev.Changed:Connect( function () |
15 | if curlev.Value = = 0 or curlev.Value = = 1 then |
16 | setParent(LightingChildren, nil ) |
17 | setParent(lobby, Lighting) |
18 | Lighting.Brightness = 0 |
19 | Lighting.Ambient = Color 3. fromRGB( 0 , 0 , 0 ) |
20 | Lighting.OutdoorAmbient = Color 3. fromRGB( 0 , 0 , 0 ) |
21 | elseif curlev.Value = = 4 then |
22 | setParent(LightingChildren, lobby) |
23 | setParent(abandonedoffice, Lighting) |
24 | Lighting.Brightness = 1 |
25 | Lighting.Ambient = Color 3. fromRGB( 22 , 22 , 22 ) |
26 | Lighting.OutdoorAmbient = Color 3. fromRGB( 0 , 0 , 0 ) |