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
local Lighting = game:GetService("Lighting") local ReplicatedStorage = game:GetService("ReplicatedStorage") local lobby = ReplicatedStorage.Lobby:GetChildren() local abandonedoffice = ReplicatedStorage.AbandonedOffice:GetChildren() local LightingChildren = Lighting:GetChildren() local curlev = workspace["CurLevel"] local function setParent(children, parent) for _, child in ipairs(children) do child.Parent = parent end end curlev.Changed:Connect(function() if curlev.Value == 0 or curlev.Value == 1 then setParent(LightingChildren, nil) setParent(lobby, Lighting) Lighting.Brightness = 0 Lighting.Ambient = Color3.fromRGB(0,0,0) Lighting.OutdoorAmbient = Color3.fromRGB(0,0,0) elseif curlev.Value == 4 then setParent(LightingChildren, lobby) setParent(abandonedoffice, Lighting) Lighting.Brightness = 1 Lighting.Ambient = Color3.fromRGB(22,22,22) Lighting.OutdoorAmbient = Color3.fromRGB(0,0,0) end end)
I believe I have spotted the issue.
On line 22 you have setParent(LightingChildren, lobby)
However lobby is set as a table. To set somethings parent it must be an instance
So you are basically telling the code to get these parts and have the parent a table, which will not work.
I feel like you might have got confused with 'lobby' being the lobby stored from replicated storage, so the code might be:
setParent(LightingChildren, game.ReplicatedStorage.Lobby)