This is supposed to change Light (LightBulb) to yellow and then back to its original color (Institutional white) after one second. Is there another way to change it back to white after one second without saying Light.BrickColor = BrickColor.new("Institutional white") ?
Button = script.Parent Light = game.Workspace.Part2 Button.ClickDetector.MouseClick:connect(function() Light.BrickColor = BrickColor.new("New Yeller") wait(1) Light.BrickColor = BrickColor.new("Institutional white") end)
Well, if you really dislike naming the colors, you can also use Color3.fromRGB(R,G,B)
which if you have the Red Green and Blue value of your colors you can do this:
local Button = script.Parent -- local variables are better then global ones local Light = game.Workspace.Part2 Button.ClickDetector.MouseClick:Connect(function() -- :Connect over :connect --Light.BrickColor = BrickColor.new("New Yeller") Light.Color = Color3.fromRGB(0,0,255) -- I think this is the color for yellow you can check wait(1) Light.Color = Color3.fromRGB(255,255,255) -- 90% sure this is white --Light.BrickColor = BrickColor.new("Institutional white") end)
This also gives you more variety over color rather then one of the pallets.
Hope this is what you were looking for.
I started working on an answer yesterday, but I ran out of time.
................
Like BlackOrange3343 said, you can't really shorten that. One solution, like BlackOrange3343 mentioned, is using the Color3.fromRBG(r, g, b) function with an rgb input. You can search up "color picker" on google to find rgb values. Another way is to name the given colors like this:
local button = script.Parent -- Local variables are better than global ones, and all variable names should start with a lowercase. local light = game.Workspace.Part2 -- Consider changing the name "Part2" to something like "Light" so it's easier to understand local yellow = Color3.fromRGB(255, 255, 0) -- The RGB value for Yellow is [255, 255, 0] local white = Color3.fromRGB(255, 255, 255) -- The RGB value for White is [255, 255, 255] local function colorChange() -- It's better to define functions with names. Light.Color = yellow -- Light.Color = Color3.fromRGB(255, 255, 0) -- Light.BrickColor = BrickColor.new("New Yeller") wait(1) Light.Color = white -- Light.Color = Color3.fromRGB(255, 255, 255) -- The RGB value for White is [255, 255, 255] -- Light.BrickColor = BrickColor.new("Institutional white") end button.ClickDetector.MouseClick:Connect(colorChange) -- Use the :Connect function over :connect