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

Smooth Color Changing Brick?

Asked by 6 years ago

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:

01while 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")
View all 30 lines...

This is what I've just temporarily used as I am still asking for help.

5 answers

Log in to vote
0
Answered by
yyyyyy09 246 Moderation Voter
6 years ago

**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--]]
06local 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 
14local tweenService = game:GetService("TweenService")
15 
View all 47 lines...
0
Thank you so much, this worked for me! :) BanarMar -1 — 6y
0
sorry Zenith, I was literally doing it as you were doing, I only saw your answer after posting, but in this it's less of a hassle only using a single for loop, rather than 2. It's also easier to understand for beginners yyyyyy09 246 — 6y
0
Yeah, that's true, I agree. IMHO I think that Color3:lerp() is more simple (to me) than Tween because I'm used to Part lerping. I agree on the single loop, though. Although, why do you create a new function for ColorChange? It looks to me as it can just go in the for loop. Zenith_Lord 93 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
1while true do
2    script.Parent.BrickColor = BrickColor.Random()
3    wait(0.05)
4end

Is that what you're asking for?

0
If this is not desirable, just change each wait() to wait 0.05 seconds. DeceptiveCaster 3761 — 6y
0
Actually, you WOULD have to do this while setting shades of the desired colors, which creates a neat rainbow effect. DeceptiveCaster 3761 — 6y
0
Nope, i need a color changing brick that transitions SMOOTHLY, it's like as if it's naturally changing color. Not just from one color to another without a transition. BanarMar -1 — 6y
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You can use property tweening to achieve this. This is not gui tweening. You can find a tutorial here.

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

To create a smooth color-changing brick, I used Color3:lerp().

Here's the code:

01local brick = script.Parent
02 
03local colors = {} -- Use a table to store the colors
04table.insert(colors, BrickColor.new("Steel blue").Color) -- Use Color3 instead of BrickColor
05table.insert(colors, BrickColor.new("Bright violet").Color)
06table.insert(colors, BrickColor.new("Magenta").Color)
07table.insert(colors, BrickColor.new("Neon orange").Color)
08table.insert(colors, BrickColor.new("Bright yellow").Color)
09table.insert(colors, BrickColor.new("Lime green").Color)
10table.insert(colors, BrickColor.new("Toothpaste").Color)
11 
12brick.Material = Enum.Material.Neon
13 
14while true do
15 
View all 29 lines...
Log in to vote
0
Answered by 5 years ago

Im sorry to bring this back up, but if you'd like something very simple and goes through the whole spectrum, use this!

1local Brick = script.Parent -- Put the part you are changing
2local speed = 1 -- The speed that the colors change
3while true do
4    for i = 0,1,0.001*speed do
5        Brick.Color = Color3.fromHSV(i,1,1)
6        wait()
7    end
8end

Answer this question