If v:IsA("SpotLight") doesnt work

Im trying to make a script that changes the color of all lights in game.

When I try and change the color of all the spotlights it just errors and says color is not a valid member of v?

for i,v in pairs (workspace.Lights:GetDescendants()) do
	if v:IsA("SpotLight") and script.Parent.Activated.Value == true then
		while true do
			v.Color = Color3.fromRGB(255, 0, 0)
			wait(1)
			v.Color = Color3.fromRGB(255,255,255)
			wait(1)
			v.COlor = Color3.fromRGB(0,0,0)
		end
	elseif script.Parent.Activated.Value == false then
		v.Color = Color3.fromRGB(255,255,255)
	end
end	

You have COlor instead of Color. Also, why is this wrapped in a while true do?

1 Like

I wrapped this in a while true do so every second it will change the color

Alright, understandable. Anyways, you have some misspelling in your code. It says COlor is not a valid member of v because it thought it wasn’t the property, but instead a child.

1 Like

Alright so I realized at the elseif statement I forgot to put if v:IsA(“SpotLight”) then

1 Like