Error with a Color3 value

I want the code to pick a random color, using the math.random(0,255) that I have setup (with rColor, gColor, bColor) but instead it gives me an error…

Code:

local plr = game.Players.LocalPlayer
local frame = plr.PlayerGui.ControlUI.MainFrame
local lightbutton = frame.LightButton
local options = lightbutton.Frame
local onB = options.On
local offB = options.Off
local auto = options.Auto
local AutomaticActive = false
lightbutton.MouseButton1Click:Connect(function()
	options.Visible = not options.Visible
end)
onB.MouseButton1Click:Connect(function()
	local lightsfolder = game.Workspace.Lights
	for i = 1,4 do
			local currentroof = lightsfolder:FindFirstChild("Roof" .. i) 
			print("Turning "..currentroof.Name.." on.")
			currentroof.part.Material = Enum.Material.Neon
			currentroof.part.Light.Enabled = true
			currentroof.part.Light.Color = Color3.fromRGB(255, 255, 255)
			currentroof.part.BBG.TextLabel.Text = currentroof.Name
			currentroof.part.BBG.TextLabel.Visible = true
			wait(0.2)
		end
	for e = 1,4 do
			local currentled = lightsfolder:FindFirstChild("LEDStrip"..e)
			print("Turning "..currentled.Name.." on.")
			currentled.Main.LED.Material = Enum.Material.Neon
			currentled.Main.LED.Beam.Enabled = true
			currentled.Main.LED.SurfaceLight.Enabled = true
			currentled.Main.LED.SurfaceLight.Color = Color3.fromRGB(255, 255, 255)
			wait(0.2)
		end
end)
offB.MouseButton1Click:Connect(function()
	local lightsfolder = game.Workspace.Lights
	for i = 1,4 do
		local currentroof = lightsfolder:FindFirstChild("Roof" .. i) 
		print("Turning "..currentroof.Name.." on.")
		currentroof.part.Material = Enum.Material.Plastic
		currentroof.part.Light.Enabled = false
		currentroof.part.BBG.TextLabel.Visible = false
		wait(0.2)
	end
	for e = 1,4 do
		local currentled = lightsfolder:FindFirstChild("LEDStrip"..e)
		print("Turning "..currentled.Name.." on.")
		currentled.Main.LED.Material = Enum.Material.Plastic
		currentled.Main.LED.Beam.Enabled = false
		currentled.Main.LED.SurfaceLight.Enabled = false
		wait(0.2)
	end
end)
auto.MouseButton1Click:Connect(function()
	if AutomaticActive == false then
		AutomaticActive = true
		auto.Text = "Turn off Automatic"
		while true do
			local LightsFolder = game.Workspace.Lights
			local rColor = math.random(0, 255)
			local gColor = math.random(0, 255)
			local bColor = math.random(0, 255)
			print("RGB for light: " .. rColor, gColor, bColor)
			local selectedLEDStrips = {}
			for _ = 1, 3 do
				local LEDStripSelected = LightsFolder:FindFirstChild("LEDStrip" .. math.random(1, 4))
				if LEDStripSelected then
					selectedLEDStrips[#selectedLEDStrips + 1] = LEDStripSelected
				end
			end
			for _, LEDStripSelected in pairs(selectedLEDStrips) do
				local TurnOn = math.random() < 0.5
				if TurnOn == false then
					LEDStripSelected.Main.LED.Material = Enum.Material.Plastic
					print("Setting material to Plastic for " .. LEDStripSelected.Name)
				else
					LEDStripSelected.Main.LED.Material = Enum.Material.Neon
					print("Setting material to Neon for " .. LEDStripSelected.Name)
				end
				LEDStripSelected.Main.LED.Beam.Enabled = TurnOn
				print("Setting Beam.Enabled to " .. tostring(TurnOn) .. " for " .. LEDStripSelected.Name)
				LEDStripSelected.Main.LED.SurfaceLight.Enabled = TurnOn
				print("Setting SurfaceLight.Enabled to " .. tostring(TurnOn) .. " for " .. LEDStripSelected.Name)
				LEDStripSelected.Main.LED.Beam.Color = Color3.fromRGB(rColor, gColor, bColor)
				LEDStripSelected.Main.LED.SurfaceLight.Color = Color3.fromRGB(rColor, gColor, bColor)
			end

			wait(2)
		end
		print("Automatic mode activated")
	else
		AutomaticActive = false
		auto.Text = "Start Automatic"
		print("Automatic mode deactivated")
	end
end)

The error:

Unable to assign property Color. ColorSequence expected, got Color3  -  Client - LightMain:83

The automatic code is inside the auto.MouseButton1Click:Connect function…

Thanks for the people that can help!

3 Likes

You can just do this if you want to change color

ColorSequence.new(Color3.fromRGB(rColor,gColor,bColor))
1 Like

Apologies if this doesn’t help, but change Beam.Color and SurfaceLight.Color to Beam.Color3 and SurfaceLight.Color3

1 Like

Unable to assign property Color. Color3 expected, got ColorSequence - Client - LightMain:84

1 Like

Change it back to Color3 for that line, literally do what the error says every time

1 Like

Color3 is not a valid member of Beam "Workspace.Lights.LEDStrip1.Main.LED.Beam" - Client - LightMain:83

1 Like

Are you trying to do beam color or sutface light?

1 Like

Beam Color, and SurfaceLight color

1 Like

Oh so, basically you need to make the Color in Beam be a ColorSequence and the one with SurfaceLight is just normal, so like this:

LEDStripSelected.Main.LED.Beam.Color = ColorSequence.new(Color3.fromRGB(rColor,gColor,bColor))
LEDStripSelected.Main.LED.SurfaceLight.Color. = Color3.fromRGB(rColor, gColor, bColor)
1 Like

You need to give the ColorSequence a table of keypoints.

LEDStripSelected.Main.LED.Beam.Color = ColorSequence.new({ColorSequenceKeypoint.new(0, Color3.fromRGB(rColor,gColor,bColor)),ColorSequenceKeypoint.new(1, Color3.fromRGB(rColor,gColor,bColor)})
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.