Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to accomplish smooth brickcolor transitioning?

Asked by 7 years ago

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.

3 answers

Log in to vote
5
Answered by 7 years ago
Edited 7 years ago

You really can't

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
Color will equal the slow transition from white to red.

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
Not a very smooth transition

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!

If I helped, please don't forget to accept my answer.
1
Thanks for explaining this much better, and thanks for the help! The_Sink 77 — 7y
0
You can better than this, with limitations BlueTaslem 18071 — 7y
Ad
Log in to vote
0
Answered by 4 years ago

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
Log in to vote
-4
Answered by 7 years ago

Try this, Put it inside the part you want to 'rainbowify'

part = script.Parent

while true do
    wait(.1)
    part.BrickColor = BrickColor.Random()
end
0
That will be a random color, not a transition. User#11440 120 — 7y

Answer this question