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")
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!
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
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
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! :)