Edit multiple parts in model as group

I am attempting to make a synchronized lighting system using grids of 9 “lamps”
image
image

I am trying to control them as a group but i am not sure how to do that.

I have tried using get decendants/children but there is a surfacelight in each one which prevents that solution from working. I have tried referencing each one sperately but that was much to tedious with so may lamps.

Any ideas?

You can get them all in group and edit them through loop for:
local group = {}

for _, lamp in pairs(lamps:GetChildren()) do
    for _,child in pairs(lamp:GetChildren()) do
        if child:IsA('BasePart') and i:FindFirstChildWhichIsA('SurfaceLight') then
            table.insert(group,child)
        end
    end
end

for _, i in pairs(group) do
   source
end

2 Likes
local lamps = workspace.Lamps --Path to lamps.

local function toggleLamps(bool)
	for _, lamp in ipairs(lamps:GetChildren()) do
		if lamp:IsA("BasePart") then
			if lamp.Name:match("^lamp%d+$") then
				local light = lamp:FindFirstChildWhichIsA("Light")
				if light then
					light.Enabled = bool
				end
			end
		end
	end
end

toggleLamps(true) --Turn on all lights.
toggleLamps(false) --Turn off all lights.

The methods dont seem to work,
is there a way to mirror the same script in all of the other 8 lamps

local Light = script.Parent.SurfaceLight

while true do
	lamp.Material =Enum.Material.Plastic
	lamp.BrickColor = BrickColor.new("Really Black")
	Light.Enabled = false
	wait(0.2)
	lamp.Material =Enum.Material.Neon
	local BrickColor = BrickColor.Random()
	local Color = BrickColor.Color
	lamp.Color = Color
	Light.Enabled = true
	Light.Color = lamp.Color
	wait(0.2)
end```
![image|148x214](upload://zj8nE0QA7Zqt3GUrNHwJX1en2zR.png)
this works but all the colors are different. in each lamp

you should look at @pupersuperkirill suggestion, for what you are trying to do it would be the simplest way

Im not sure how to use it. where do i edit the properties? @pupersuperkirill

So this code…

puts all of the parts that have a surface light in them into a table inside a script so they can be indexed

and this is where you would put your code for the surface lights (Where it says Source)

So where it says source you would put something like…

LightPart:FindFirstChildWhichIsA('SurfaceLight').Enabled = false

Some code may not be exact i just wrote this