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

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

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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
0
Thanks! This worked. blackdiamond34 2 — 5y
Ad

Answer this question