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 8 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 8 years ago
Edited 8 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,

1local start = Color3.new(1,1,1)-- White
2local End = Color3.new(1,0,0)--Red
3 
4for i = 0,1,0.03 do
5    wait()
6    local color = start:lerp(End,i)
7end
Color will equal the slow transition from white to red.

Using this method is great for GUIs, because they use the exact color3 value.

1-- Inside Frame
2local start = Color3.new(1,1,1)-- White
3local End = Color3.new(1,0,0)--Red
4 
5for i = 0,1,0.03 do
6    wait()
7    script.Parent.BackgroundColor3 = start:lerp(End,i)
8end

For BrickColors though, it's obviously not as smooth.

1-- Inside Part
2local start = Color3.new(1,1,1)-- White
3local End = Color3.new(1,0,0)--Red
4 
5for i = 0,1,0.03 do
6    wait()
7    local color = start:lerp(End,i)
8    script.Parent.BrickColor = BrickColor.new(color)
9end
Not a very smooth transition

You could make a randomly changing color brick by doing this,

01-- Inside Part
02local start = Color3.new(1,1,1)
03 
04while true do
05    start = Color3.new(1,1,1)-- Whit/LastColor
06    local End = Color3.new(math.random(),math.random(),math.random())-- Random Color
07    for i = 0,1,0.03 do
08        wait()
09        local color = start:lerp(End,i)
10        script.Parent.BrickColor = BrickColor.new(color)
11    end
12    start = End-- Resets Start variable
13end

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 — 8y
0
You can better than this, with limitations BlueTaslem 18071 — 8y
Ad
Log in to vote
0
Answered by 5 years ago

Making a rainbow cycling brick is really easy. The easiest way is to use BrickColor:

1local rainbowbrick = script.Parent
2 
3while true do
4    rainbowbrick.BrickColor = BrickColor.new("the first BrickColor you want the part to change to")
5    wait(--interval between colors in seconds)
6    rainbowbrick.BrickColor = BrickColor.new("the second BrickColor you want the part to change to")
7    wait(--interval between colors in seconds)
8    --And keep adding the BrickColor lines and waits. Make sure a wait is on the last line.
9end

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:

01local rainbowbrick = script.Parent
02 
03while true do
04wait(1)
05rainbowbrick.BrickColor = BrickColor.new("Really red")
06wait(1)
07rainbowbrick.BrickColor = BrickColor.new("Deep orange")
08wait(1)
09rainbowbrick.BrickColor = BrickColor.new("New Yeller")
10wait(1)
11rainbowbrick.BrickColor = BrickColor.new("Forest green")
12wait(1)
13rainbowbrick.BrickColor = BrickColor.new("Cyan")
14wait(1)
15rainbowbrick.BrickColor = BrickColor.new("Magenta")
16end
Log in to vote
-4
Answered by 8 years ago

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

1part = script.Parent
2 
3while true do
4    wait(.1)
5    part.BrickColor = BrickColor.Random()
6end
0
That will be a random color, not a transition. User#11440 120 — 8y

Answer this question