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!