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

help with making a color changing part?

Asked by 4 years ago

how do i make a rainbow part?

do i have to do like this?

1part.BrickColor = BrickColor.new("Bright red")
2part.BrickColor = BrickColor.new("Lapis")
3part.BrickColor = BrickColor.new("Black")
4part.BrickColor = BrickColor.new("Pink")

3 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

you have to make your part change its color. like with looping:

1while wait() do
2part.BrickColor = BrickColor.new("Bright red")
3wait(.5)
4part.BrickColor = BrickColor.new("Lapis")
5wait(.5)
6part.BrickColor = BrickColor.new("Black")
7wait(.5)
8part.BrickColor = BrickColor.new("Pink") end

OR to make it more rainbow:

01local r = 1
02local g = 249
03local b = 100
04local rD = true
05local gD = false
06local bD = true
07while wait() do
08part.Color = Color3.new(r, g, b)
09if r >= 250 then rD = false elseif r <= 0 then rD = true end
10if b >= 250 then bD = false elseif b <= 0 then bD = true end
11if g >= 250 then gD = false elseif g <= 0 then gD = true end
12if rD == true then r = r + 1 else r = r - 1 end
13if bD == true then b = b + 1 else b = b - 2 end
14if gD == true then g = g + 2 else g = g - 1 end
15end

Hope i was able to help! good day!

0
I discovered i did it very complicating-ly.... but it works TheEagle722 170 — 4y
0
I think you overcomplicated it. I don't even understand what's really going on, you have to elaborate when posting an answer, not just post one. 2Loos 168 — 4y
0
I'm honestly sorry. i like complicated things. TheEagle722 170 — 4y
Ad
Log in to vote
1
Answered by
2Loos 168
4 years ago
Edited 4 years ago

That script will work, but the colors will change so fast that you won't have time to notice. That approach is better if you don't want the colors abruptly changing. You can use TweenService to get a smooth effect. For the color cycle to keep repeating, use a while true do loop.

Examples: 1. Abruptly changes, but does the job!

01while true do
02    part.BrickColor = BrickColor.new("Bright red")
03    wait(1)
04    part.BrickColor = BrickColor.new("Lapis")
05    wait(1)
06    part.BrickColor = BrickColor.new("Black")
07    wait(1)
08    part.BrickColor = BrickColor.new("Pink")
09    wait(1)
10end
  1. This script wasn't made by me, but a lot of changes were made. Many deprecated items such as Wait() were used. This uses a while wait() do loop, and changes over colors smoothly.
01while wait() do
02    script.Parent.Color = Color3.new(255/255,0/255,0/255)
03    for i = 0,255,10 do
04        wait()
05        script.Parent.Color = Color3.new(255/255,i/255,0/255)
06    end
07    for i = 255,0,-10 do
08        wait()
09        script.Parent.Color = Color3.new(i/255,255/255,0/255)
10    end
11    for i = 0,255,10 do
12        wait()
13        script.Parent.Color = Color3.new(0/255,255/255,i/255)
14    end
15    for i = 255,0,-10 do
View all 27 lines...
Log in to vote
0
Answered by 4 years ago

Hey there!

Your script probably isn't giving you any error - this is because there technically isn't any. However, the computer is processing your code really, really quickly. It is so fast, that you can't even see the colors changing. What you need to do is to add time in between each color change.

For example:

1part.BrickColor = BrickColor.new("Bright red")
2wait(3) -- This would cause the script to pause for 3 seconds
3part.BrickColor = BrickColor.new("Lapis")

If you want to make your script a little more complicated, you could make the colors change forever. You can simply do this within a loop. (Don't forget to add wait(#) between each change!)

1while true do
2    part.BrickColor = BrickColor.new("Bright red")
3    wait(3) -- This would cause the script to pause for 3 seconds
4    part.BrickColor = BrickColor.new("Lapis")
5    wait(3) -- This would cause the script to pause for 3 seconds
6end

If you have any more question, let me know and I'm happy to help! :)

0
Well technically if you have a really slow computer you could probably see the colors for a millisecond- lol Galaxybombboy 134 — 4y
0
thanks! i will try this when i get back on my computer NexterDev 13 — 4y

Answer this question