BrickColor.Random Exceptions

I am making a script that changes a block’s colour every .1 seconds, using .random, so it’s not just the same repeated pattern, and I don’t have to spend ages looking for colours.

Problem is, there are some colours it can’t be like Black, Really black, Pine cone & bright blue.

Is there any way I can exclude these colours?

What you could try doing is using a while loop to generate colors until they’re not black really black… etc.

1 Like

That would take too long, and make it harder to be able to go through the script.

It’s also a very specific script, that would end up adding a delay. It’s a specific pattern that goes from fast to slow.

another thing you could try is making an array with all the possible brick colors and then just remove the ones that you wouldn’t want to include. However, what you said about adding a delay isn’t really true considering it won’t have a wait statement within the for loop, and since you only have a few colors, it wouldn’t affect performance.

1 Like

Can you give an example line or do I just do that with .random(“colour”, “colour”, “colour”)

I found this tutorial - Example on how to get all brickcolors - Resources / Community Tutorials - Developer Forum | Roblox

Basically, you would just do

local Colors = {}

for i = 1, 1032 do
    local BrickColorValue = BrickColor.new(i)
    if not table.find(Colors, BrickColorValue) and BrickColorValue ~= "undesired value" then
        table.insert(Colors, BrickColorValue)
    end
end
--use this statement anytime you need to get a random color:
local randomColor = Colors[math.random(#Colors)]
1 Like

Definitely will not be able to work that in. Ever
image

Here’s a script that might work for you:

local Colors = {}

for i = 1, 1032 do
    local BrickColorValue = BrickColor.new(i)
    if not table.find(Colors, BrickColorValue) and BrickColorValue ~= "undesired value" then
        table.insert(Colors, BrickColorValue)
    end
end

while true do
    p1.BrickColor =  Colors[math.random(#Colors)]
--rest of your script
end
2 Likes

So do I just paste the rest in, then?

well you would need to set the p1/p2/p3 brick color to Colors[math.random(#Colors)], but then yes, you would

1 Like

As in I just need to add p2 and p3 under p1, or?

Sorry I only know enough about scripting to make frames, I’m not familiar with this kind of stuff

1 Like

Yes, and then you want to make sure the if statement
if not table.find(Colors, BrickColorValue) and BrickColorValue ~= "undesired value" then includes your brick values as undesired values

1 Like

Assume I can just add a comma, then the next values?

no, you would have to add and BrickColorValue ~= “undesired value” for every color value you don’t want

1 Like

Used the

or

function, worked perfectly

1 Like

Oh god learn collectionservice, it will organize this so much…

1 Like

Never heard of it. I honestly don’t care either. It’s a dancefloor pattern not the entire game

All of your code would be 4 lines bro.
Its so much faster, way less work, way more efficient

Is there a documentation page?