I'm trying to make a light switch that can enable or disable lights in a folder when I try to, the output says it can't find anything in the folder, the part doesn't show up in the suggestions box either. This is the script I'm using, (not including the light switch) it only enables and disables one light and works, but it would get crowded quickly and would look bad if I did this for everything.

if open == false then
	workspace.Light.SurfaceLight.Enabled = true
	workspace.Light.Material = Enum.Material.Neon
	workspace.Light.BrickColor = BrickColor.new("Light stone grey")

	script.Parent.Parent.Parent.LightsA.Green.Transparency = 0
	script.Parent.Parent.Parent.LightsA.Green.Material = Enum.Material.Neon
	script.Parent.Parent.Parent.LightsA.Red.Transparency = .3
	script.Parent.Parent.Parent.LightsA.Red.Material = Enum.Material.Glass
else
	workspace.Light.SurfaceLight.Enabled = false
	workspace.Light.Material = Enum.Material.Glass
	workspace.Light.BrickColor =  BrickColor.new("Black")
	
	script.Parent.Parent.Parent.LightsA.Green.Transparency = .3
	script.Parent.Parent.Parent.LightsA.Green.Material = Enum.Material.Glass
	script.Parent.Parent.Parent.LightsA.Red.Transparency = 0
	script.Parent.Parent.Parent.LightsA.Red.Material = Enum.Material.Neon
end
	   end
end)

Thanks in advance if you're able to help me.

3 comments

0

If i understand correctly, you want to change the properties of multiple parts. If this is the case use a for loop (e.g. For _, v in pairs(script.Parent.Parent.Parent:GetChildren()) do code end

0

I'll give it a try

0

did it work?