I am attempting to make a synchronized lighting system using grids of 9 “lamps”
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.
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
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