Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a brick change to a random color except a specific one?

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?

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

1 comment

0

Thanks! This worked.

This discussion is preserved as it was. New answers, comments, and votes are closed.