I am trying to get all the PointLights in a model. They are embedded in model in a model in a model, etc.
Here is my current code. I want lights array to be all the PointLights. named PointLight.
local lights = {} local children = house:GetChildren() for i = 1, #children do if children[i].Name == "PointLight" then lights.append(children[i]) end end
On a side note is .append() a real thing in LUA? (I have not tested it because I cannot get there)
children
is contains just the direct descendants of house
local thing = game.Workspace --place to be searched for i,things in pairs(thing:GetDescendants()) do -- or :GetChildren() if things:IsA("PointLight") then things:Destroy() -- JUST A CODE end end
Just loop through the children in the model and check if they inherit the "PointLight" class, like so.
local lights = {} for i, child in pairs(house:GetChildren()) do if child:IsA("PointLight") then table.insert(light, child) -- insert `child` into the table `light`. end end