So the code for the Spotlight but I added the Part new color and it does not work now? Any issues you see here or you simply can't do x2?
script.Parent.MouseButton1Down:Connect(function() if game.Workspace.Games.Colors.ColorsLightSystem.CeilingWhite.Value.Value == true then game.Workspace.Games.Colors.ColorsLightSystem.CeilingWhite.Value.Value = false for _, v in pairs(workspace.Games.Colors.ColorsLightSystem.CeilingWhite:GetDescendants()) do if v:IsA("SpotLight") then v.Brightness = 10 for _, v in pairs(workspace.Games.Colors.ColorsLightSystem.CeilingWhite:GetDescendants()) do if v:IsA("Part") then v.BrickColor.new ("Mid gray") end end else game.Workspace.Games.Colors.ColorsLightSystem.CeilingWhite.Value.Value = true for _, v in pairs(workspace.Games.Colors.ColorsLightSystem.CeilingWhite:GetDescendants()) do if v:IsA("SpotLight") then v.Brightness = 0 for _, v in pairs(workspace.Games.Colors.ColorsLightSystem.CeilingWhite:GetDescendants()) do if v:IsA("Part") then v.BrickColor.new ("Institutional white") end end end end while wait() do if game.Workspace.Games.Colors.ColorsLightSystem.CeilingWhite.Value.Value == false then script.Parent.ImageColor3 = Color3.fromRGB(130, 243, 0) else script.Parent.ImageColor3 = Color3.fromRGB(163, 162, 165) end end
Your code is really messed up. You made some syntax errors where you tried to set the BrickColor, you put a loop inside the same loop, you don't use variables for the ceiling and you use a while loop to check if the value has changed!
Everything wrong!!!!!
Here is what it should look like:
local ceiling = workspace.Games.Colors.ColorsLightSystem.CeilingWhite --declare it as a variable script.Parent.MouseButton1Down:Connect(function() if ceiling.Value.Value == true then ceiling.Value.Value = false for _, v in pairs(ceiling:GetDescendants()) do if v:IsA("SpotLight") then v.Brightness = 10 elseif v:IsA("BasePart") then --check if it's a part v.BrickColor = BrickColor.new("Mid gray") --set the color like this end end else ceiling.Value.Value = true for _, v in pairs(ceiling:GetDescendants()) do if v:IsA("SpotLight") then v.Brightness = 0 elseif v:IsA("BasePart") then v.BrickColor = BrickColor.new("Institutional white") end end end end ceiling.Value.Changed:Connect(function(val) --use the Changed event to check if the value has changed if val then script.Parent.ImageColor3 = Color3.fromRGB(163, 162, 165) else script.Parent.ImageColor3 = Color3.fromRGB(130, 243, 0) end end)