SpryKirby
|
  |
| Joined: 22 Mar 2016 |
| Total Posts: 78 |
|
|
| 20 Jun 2017 06:39 AM |
| How can I make a script in such a way that a brick can smoothly fade into a new color. |
|
|
| Report Abuse |
|
tball146
|
  |
| Joined: 02 Apr 2013 |
| Total Posts: 363 |
|
|
| 20 Jun 2017 06:59 AM |
ive had questions about this too but i do not know
plus its not that interesting anymore to me |
|
|
| Report Abuse |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 20 Jun 2017 07:03 AM |
This is possible. This is easy.
All you need to do is use BrickColor.new(Color3.new(r,g,b)) with your lerp. It certainly won't be totally smooth but it is possible.
...like so:
local part = script.Parent local oldColor = part.BrickColor local destination = BrickColor.new("Pastel yellow") -- example for i = 0,1,1/200 do -- over a couple hundred steps part.BrickColor = BrickColor.new(part.BrickColor.Color:lerp(destination.Color,i)) wait() end
A better way to do this, would be to log every unique brickcolor, and smoothly lerp those to avoid "jumps"
local part = script.Parent local oldColor = part.BrickColor local destination = BrickColor.new("Pastel yellow") wait(2) local colors = {} for i = 0,1,1/1000 do -- make sure we get every step in there newColor = BrickColor.new(part.BrickColor.Color:lerp(destination.Color,i)) if #colors~=nil and colors[#colors] ~= newColor then table.insert(colors,newColor) end end for _,v in next,colors do part.BrickColor = v wait(2/#colors) -- how fast you want to cycle through these colors, in this case 2 seconds end newColor = BrickColor.new(part.BrickColor.Color:lerp(destination.Color,i)) if color[#colors] and color[#colors] ~= newColor then table.insert(colors,newColor) end end for _,v in next,colors do part.BrickColor = v wait(2/#colors) -- how fast you want to cycle through these colors, in this case 2 seconds end
Even still, you can use GUIs on the surface of the part. If the part is SmoothPlastic, this will work great.
local part = script.Parent local destination = Br#####################ellow") local guis = {}
for i = 0,5 do local gui = Instance.new("SurfaceGui",part) gui.Adornee = part gui.Face = i local frame = Instance.new("Frame",gui) frame.Size = UDim2.new(1,0,1,0) frame.BackgroundColor3 = part.BrickColor.Color frame.BorderSizePixel = 0 table.insert(guis,frame) end for i = 0,1,1/300 do -- over 300 steps for _,frame in next,guis do frame.BackgroundColor3 = part.BrickColor.Color:lerp(destination.Color,i) end wait() end part.BrickColor = destination for _,frame in next,guis do frame.Parent:Destroy() end
-- To avoid chops, you could lerp every color to grey, and then lerp from grey, to your desired color.
I STRONGLY recommend trying that.
|
|
|
| Report Abuse |
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 20 Jun 2017 07:16 AM |
"use BrickColor.new(Color3.new(r,g,b))"
Sometimes I wonder if I'm the only one who looks into things rather than blindly using them.
BrickColor.new(r, g, b)
http://wiki.roblox.com/index.php?title=BrickColor
|
|
|
| Report Abuse |
|
Vyxinph
|
  |
| Joined: 03 May 2017 |
| Total Posts: 12046 |
|
| |
SpryKirby
|
  |
| Joined: 22 Mar 2016 |
| Total Posts: 78 |
|
|
| 20 Jun 2017 07:52 AM |
| @Soybeen TYSM! Can't wait to try! |
|
|
| Report Abuse |
|