Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

help with making a color changing part?

Asked by 2 days ago

how do i make a rainbow part?

do i have to do like this?

part.BrickColor = BrickColor.new("Bright red")
part.BrickColor = BrickColor.new("Lapis")
part.BrickColor = BrickColor.new("Black")
part.BrickColor = BrickColor.new("Pink")

3 answers

Log in to vote
1
Answered by 2 days ago
Edited 2 days ago

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

while wait() do
part.BrickColor = BrickColor.new("Bright red")
wait(.5)
part.BrickColor = BrickColor.new("Lapis")
wait(.5)
part.BrickColor = BrickColor.new("Black")
wait(.5)
part.BrickColor = BrickColor.new("Pink") end

OR to make it more rainbow:

local r = 1
local g = 249
local b = 100
local rD = true
local gD = false
local bD = true
while wait() do
part.Color = Color3.new(r, g, b)
if r >= 250 then rD = false elseif r <= 0 then rD = true end
if b >= 250 then bD = false elseif b <= 0 then bD = true end
if g >= 250 then gD = false elseif g <= 0 then gD = true end
if rD == true then r = r + 1 else r = r - 1 end
if bD == true then b = b + 1 else b = b - 2 end
if gD == true then g = g + 2 else g = g - 1 end
end

Hope i was able to help! good day!

0
I discovered i did it very complicating-ly.... but it works TheEagle722 99 — 2d
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 108 — 2d
0
I'm honestly sorry. i like complicated things. TheEagle722 99 — 2d
Ad
Log in to vote
1
Answered by
2Loos 108
2 days ago
Edited 2 days 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!

while true do
    part.BrickColor = BrickColor.new("Bright red")
    wait(1)
    part.BrickColor = BrickColor.new("Lapis")
    wait(1)
    part.BrickColor = BrickColor.new("Black")
    wait(1)
    part.BrickColor = BrickColor.new("Pink")
    wait(1)
end
  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.
while wait() do
    script.Parent.Color = Color3.new(255/255,0/255,0/255)
    for i = 0,255,10 do
        wait()
        script.Parent.Color = Color3.new(255/255,i/255,0/255)
    end
    for i = 255,0,-10 do
        wait()
        script.Parent.Color = Color3.new(i/255,255/255,0/255)
    end
    for i = 0,255,10 do
        wait()
        script.Parent.Color = Color3.new(0/255,255/255,i/255)
    end
    for i = 255,0,-10 do
        wait()
        script.Parent.Color = Color3.new(0/255,i/255,255/255)
    end
    for i = 0,255,10 do
        wait()
        script.Parent.Color = Color3.new(i/255,0/255,255/255)
    end
    for i = 255,0,-10 do
        wait()
        script.Parent.Color = Color3.new(255/255,0/255,i/255)
    end
end
Log in to vote
0
Answered by 2 days 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:

part.BrickColor = BrickColor.new("Bright red")
wait(3) -- This would cause the script to pause for 3 seconds
part.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!)

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

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 39 — 2d
0
thanks! i will try this when i get back on my computer NexterDev 9 — 1d

Answer this question