I'm trying to figure out how i can make a brick transition between colors smoothly. Im trying to make it transition through all the colors of the rainbow. I mean, its a simple thing, but i cant seem to figure out how to accomplish that.
Roblox has default brick colors. You can't add more. Here's a link to all the Color Codes.
The closest you can come is by using Color3
, but even then roblox picks the closest BrickColor
to that Color3
color.
If you want to try this though, there a Color3
lerp
function. Example,
local start = Color3.new(1,1,1)-- White local End = Color3.new(1,0,0)--Red for i = 0,1,0.03 do wait() local color = start:lerp(End,i) end
Using this method is great for GUIs, because they use the exact color3 value.
-- Inside Frame local start = Color3.new(1,1,1)-- White local End = Color3.new(1,0,0)--Red for i = 0,1,0.03 do wait() script.Parent.BackgroundColor3 = start:lerp(End,i) end
For BrickColors though, it's obviously not as smooth.
-- Inside Part local start = Color3.new(1,1,1)-- White local End = Color3.new(1,0,0)--Red for i = 0,1,0.03 do wait() local color = start:lerp(End,i) script.Parent.BrickColor = BrickColor.new(color) end
You could make a randomly changing color brick by doing this,
-- Inside Part local start = Color3.new(1,1,1) while true do start = Color3.new(1,1,1)-- Whit/LastColor local End = Color3.new(math.random(),math.random(),math.random())-- Random Color for i = 0,1,0.03 do wait() local color = start:lerp(End,i) script.Parent.BrickColor = BrickColor.new(color) end start = End-- Resets Start variable end
You could maybe use Surface Guis
to make the brick transition smoother.
Good Luck!
Making a rainbow cycling brick is really easy. The easiest way is to use BrickColor
:
local rainbowbrick = script.Parent while true do rainbowbrick.BrickColor = BrickColor.new("the first BrickColor you want the part to change to") wait(--interval between colors in seconds) rainbowbrick.BrickColor = BrickColor.new("the second BrickColor you want the part to change to") wait(--interval between colors in seconds) --And keep adding the BrickColor lines and waits. Make sure a wait is on the last line. end
The BrickColor
is the name of the color that you want to change the brick to. To get the name, hover over the color in the 'Color' dropdown in the 'Model' section in Studio.
I hope this works for you! It works in my game too. Here's an example:
local rainbowbrick = script.Parent while true do wait(1) rainbowbrick.BrickColor = BrickColor.new("Really red") wait(1) rainbowbrick.BrickColor = BrickColor.new("Deep orange") wait(1) rainbowbrick.BrickColor = BrickColor.new("New Yeller") wait(1) rainbowbrick.BrickColor = BrickColor.new("Forest green") wait(1) rainbowbrick.BrickColor = BrickColor.new("Cyan") wait(1) rainbowbrick.BrickColor = BrickColor.new("Magenta") end
Try this, Put it inside the part you want to 'rainbowify'
part = script.Parent while true do wait(.1) part.BrickColor = BrickColor.Random() end