Color is not a valid member of Camera "Workspace.Camera" Error?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to make a system where all the lights change different colors such as alarms or something

  2. What is the issue? Include screenshots / videos if possible!
    I am getting the following error:

Color is not a valid member of Camera “Workspace.Camera”

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried to look on some devforum posts and the developer hub but both have failed me.
local descendants = game.Workspace:GetDescendants()
local button = script.Parent.ClickDetector
local AlarmIsOn = false

button.MouseClick:Connect(function()
	if AlarmIsOn == false then
		AlarmIsOn = true

		for index, descendants in pairs(descendants) do
			if descendants:IsA("PointLight") then

				descendants.Color = Color3.fromRGB(255,1,1)
			else
				descendants.Color = Color3.fromRGB(255,255,255)
			end
		end
	end
end)


	






			

button.MouseClick:Connect(function()
	if AlarmIsOn == false then
		AlarmIsOn = true

		for index, descendants in pairs(descendants) do
			if descendants:IsA("PointLight") then

				descendants.Color = Color3.fromRGB(255,1,1)
			elseif descendants:IsA("BasePart") then
				descendants.Color = Color3.fromRGB(255,255,255)
			end
		end
	end
end)
1 Like

I don;t understand what happened but this surely didn’t work.

If you are trying to make only lights change color then there is no point of the else in the if statment

button.MouseClick:Connect(function()
	if AlarmIsOn == false then
		AlarmIsOn = true

		for index, descendants in pairs(descendants) do
			if descendants:IsA("PointLight") then

				descendants.Color = Color3.fromRGB(255,1,1)
			end
		end
	end
end)
1 Like

Well I do want the lights to change But I also want them to change back.

			if descendants:IsA("PointLight") then -- If the descendant is a point light only

				descendants.Color = Color3.fromRGB(255,1,1)
			else -- if the descandant is anything but a point light (parts, **cameras**, etc.)
				descendants.Color = Color3.fromRGB(255,255,255)
			end

Please do explain a bit more about what you want as your final product.

1 Like

What do you want them to change back to?

1 Like

I want it like one button. Wether you click it will change the lights on all PointLights in workspace. IF you click it again it’ll return the lights back to normal.

local descendants = game.Workspace:GetDescendants()
local button = script.Parent.ClickDetector
local AlarmIsOn = false

button.MouseClick:Connect(function()
	AlarmIsOn = not AlarmIsOn
	for index, descendants in pairs(descendants) do
		if descendants:IsA("PointLight") and AlarmIsOn then
			descendants.Color = Color3.fromRGB(255,255,255)
		elseif descendants:IsA("PointLight") then
			descendants.Color = Color3.fromRGB(255,1,1)
		end
	end
end)
1 Like
button.MouseClick:Connect(function()
	if not AlarmIsOn  then
		AlarmIsOn = true
		for index, descendants in pairs(descendants) do
			if descendants:IsA("PointLight") then
                 descendants.Color = Color3.fromRGB(255,1,1)
            end
		end
    else
   	    AlarmIsOn = false
        for index, descendants in pairs(descendants) do
			if descendants:IsA("PointLight") then
                descendants.Color = Color3.fromRGB(255,255,255)
            end
		end
	end
end)

This will make it toggle between being on and off (Assuming the color for it being off is white)

1 Like

This should be a more simplified version of what you want to achieve.

1 Like
button.MouseClick:Connect(function()
	AlarmIsOn = not AlarmIsOn
	for _, Descendant in ipairs(Descendants) do
		if Descendant:IsA("PointLight") then
			Descendant.Color = if AlarmIsOn then Color3.new(1, 0, 0) else Color3.new(1, 1, 1)
		end
	end
end)