I have a model group which has a bunch of parts, each with a light inside. Is there a way to select all of them in a script? I tried using the light’s name but nothing happens.
2 Likes
Yeah, you can use the :GetChildren()
method.
You would then use a for loop to iterate through the Parts’ light.
For example:
for _, Part in pairs(GROUPNAME:GetChildren()) do
end
Then you could do whatever you want with the lights, for example:
for _, Part in pairs(GROUPNAME:GetChildren()) do
if Part:FindFirstChild("SurfaceLight") then
Part.SurfaceLight.Enabled = false
end
end
Or if you wanted all the parts into a table you could do:
local LightParts = {}
for _, v in pairs(GROUP:GetChildren()) do
table.insert(LightParts, #LightParts+1, v)
end
2 Likes