Hello, I need help in creating a Smooth Color Changing Brick. I've seen some tutorials about brick color change but it does not make a smooth transition, it just instantly changes color. I am currently making a gaming chroma keyboard (Gaming keyboard that changes LED color from time to time, making a rainbow effect.)
Go see the PLACE so you see what I mean.
My current script for it is:
01 | while true do |
02 | script.parent.BrickColor = BrickColor.new( "Steel blue" ) |
03 | script.parent.Material = ( "Neon" ) |
04 | wait ( 3 ) |
05 |
06 | script.parent.BrickColor = BrickColor.new( "Bright violet" ) |
07 | script.parent.Material = ( "Neon" ) |
08 | wait ( 3 ) |
09 |
10 | script.parent.BrickColor = BrickColor.new( "Magenta" ) |
11 | script.parent.Material = ( "Neon" ) |
12 | wait ( 3 ) |
13 |
14 | script.parent.BrickColor = BrickColor.new( "Neon orange" ) |
15 | script.parent.Material = ( "Neon" ) |
This is what I've just temporarily used as I am still asking for help.
**This should work for your circumstances, comment if you have any questions about the code **
01 | --[[ |
02 | Keep your colors in this table, they have the |
03 | .Color property which returns their Color3 |
04 | value for tweening |
05 | --]] |
06 | local colors = { BrickColor.new( "Steel blue" ).Color, |
07 | BrickColor.new( "Bright violet" ).Color, |
08 | BrickColor.new( "Magenta" ).Color, |
09 | BrickColor.new( "Neon orange" ).Color, |
10 | BrickColor.new( "Bright yellow" ).Color, |
11 | BrickColor.new( "Lime green" ).Color, |
12 | BrickColor.new( "Toothpaste" ).Color } |
13 |
14 | local tweenService = game:GetService( "TweenService" ) |
15 |
1 | while true do |
2 | script.Parent.BrickColor = BrickColor.Random() |
3 | wait( 0.05 ) |
4 | end |
Is that what you're asking for?
You can use property tweening to achieve this. This is not gui tweening. You can find a tutorial here.
To create a smooth color-changing brick, I used Color3:lerp().
Here's the code:
01 | local brick = script.Parent |
02 |
03 | local colors = { } -- Use a table to store the colors |
04 | table.insert(colors, BrickColor.new( "Steel blue" ).Color) -- Use Color3 instead of BrickColor |
05 | table.insert(colors, BrickColor.new( "Bright violet" ).Color) |
06 | table.insert(colors, BrickColor.new( "Magenta" ).Color) |
07 | table.insert(colors, BrickColor.new( "Neon orange" ).Color) |
08 | table.insert(colors, BrickColor.new( "Bright yellow" ).Color) |
09 | table.insert(colors, BrickColor.new( "Lime green" ).Color) |
10 | table.insert(colors, BrickColor.new( "Toothpaste" ).Color) |
11 |
12 | brick.Material = Enum.Material.Neon |
13 |
14 | while true do |
15 |
Im sorry to bring this back up, but if you'd like something very simple and goes through the whole spectrum, use this!
1 | local Brick = script.Parent -- Put the part you are changing |
2 | local speed = 1 -- The speed that the colors change |
3 | while true do |
4 | for i = 0 , 1 , 0.001 *speed do |
5 | Brick.Color = Color 3. fromHSV(i, 1 , 1 ) |
6 | wait() |
7 | end |
8 | end |