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

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

01local Lighting = game:GetService("Lighting")
02local ReplicatedStorage = game:GetService("ReplicatedStorage")
03local lobby = ReplicatedStorage.Lobby:GetChildren()
04local abandonedoffice = ReplicatedStorage.AbandonedOffice:GetChildren()
05local LightingChildren = Lighting:GetChildren()
06local curlev = workspace["CurLevel"]
07 
08local function setParent(children, parent)
09    for _, child in ipairs(children) do
10        child.Parent = parent
11    end
12end
13 
14curlev.Changed:Connect(function()
15    if curlev.Value == 0 or curlev.Value == 1 then
View all 28 lines...

1 answer

Log in to vote
1
Answered by 2 years ago

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)

0
i see the problem now, it was tryna parent to all the children in the folder, thanks for this JmoneyPlayzOfficial 49 — 2y
Ad

Answer this question