I know how to make a brick change to random colors. However, I want it to remove specific colors (Gray, Brown, Black, etc) from the random script. I'm trying to make it flash, but the dull colors do not make it look great. How can I script this?
✓ ANSWER ACCEPTED
How do I make a brick change to a random color except a specific one?
1 answer
✓ Accepted answer
This should work:
local brick = script.Parent
brick.BrickColor = BrickColor.Random()
if brick.BrickColor == BrickColor.Gray or BrickColor.Black or BrickColor.Brown() then
wait()
else
brick.BrickColor = BrickColor.Random()
end
This basically checks if the picked color isn't gray or black or brown. If it is, then it changes it to something new. If this doesn't please you, you can do the same using math.random to pick a random color, except the ones you don't want. So it'll be like this:
-- this is just an example
local number = math.random(1,3)
local brick = script.Parent
if number == 1 then
brick.BrickColor = BrickColor.Red() -- so if the number 1 got chosen by math.random, it'll be red.
elseif number == 2 then
brick.BrickColor = BrickColor.Yellow()
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thanks! This worked.