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

Is there a fancy object in ROBLOX Studio to transmit from 1 color to another smoothly?

Asked by 7 years ago
Edited 7 years ago

Hey guys,

I was wondering if there is some fancy object or some cool method that I can script to make an object transmit from 1 color to another by going through smooth phases. Like, let's say from white to black, it would go: White, Light grey, Grey, Light Black, Black. Smoothly transitioning from one color to another like that by going through the phases.

Any help is appreciated.

~~ KingLoneCat

0
Color3 or Brick Color? User#13357 0 — 7y

3 answers

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

Lerp

You can use the lerp function on Color3 datatypes. "Lerp" is short for "Linear Interpolation", and takes in 2 arguments:

  • Color3 end goal: What you're trying to get to

  • Number alpha: Number between 0 and 1, acting as a percentage between start and end


Usage

Since you're looking for a smooth transition, you should use a numerical for loop. Syntax looks like this:

for [var] = [start],[finish],[(optional) increment] do

[code]

end

Use your color goal as the first argument in the Lerp function, and then your [var] divided by your [finish] to indicate a gradual climb.


Code

local part = workspace.Part --This is your part
local color = Color3.new(0,0,0) --This is the desired color; black
local smooth = 20 --This is how smooth the transition will be

for i = 1,smooth do
    local c = part.BrickColor.Color:lerp(color,i/smooth); --Aquire the color
    print(BrickColor.new(c.r,c.g,c.b));
    part.BrickColor = BrickColor.new(c.r,c.g,c.b) --Convert to BrickColor
    wait(.05)
end

Note: BrickColors and Color3s do not translate perfectly. You may notice some odd colors pop up but for the most part, the transition is normal.

0
Why did you do i/smooth for the second argument in the :lerp() is it ok if I replace that with a color3? KingLoneCat 2642 — 7y
0
I already explained that at the end of the Usage section - it will cause a gradual climb. if i is 1 then it will be 1/20, which is 5% progress in between your starting color and your wanted color. If i is 2, it will be 10%, and if i is smooth, it will be 100%. Understand? Goulstem 8144 — 7y
0
No it is not ok to replace it with a Color3. Look at my explanation on the second argument for the Lerp function .-. Goulstem 8144 — 7y
0
So, what if I want the 2 colors to be different then just black and white? Let's say I want it to be blue and pink. KingLoneCat 2642 — 7y
View all comments (4 more)
0
Then the color of the part has to already be blue, and you have to set the 'color' variable to a Color3 datatype that corresponds to pink Goulstem 8144 — 7y
0
you are such a ####### help! greatneil80 2647 — 5y
0
you are such an epic helper*! greatneil80 2647 — 5y
0
this deserves upvotes dude greatneil80 2647 — 5y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You could try this, a Color3 lerp function. For example,

local start = Color3.new(1,1,1)-- White
local End = Color3.new(0,0,0)--Black

for i = 0,1,0.03 do
    wait()
    local color = start:lerp(End,i)
end
0
"Red" RubenKan 3615 — 7y
0
Typo, fixed it now. shadow7692 69 — 7y
Log in to vote
-1
Answered by 7 years ago
  1. Make the brick white
  2. Place black decals around the brick
  3. Comment to me if you don't know how to make a smoothly decal transparency & I edit my answear
0
That's not what I meant. KingLoneCat 2642 — 7y
0
But it looks like that in the colors... MineJulRBX 52 — 7y

Answer this question