BrickColor.Random Exceptions

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?

CollectionService in a nutshell

So it’s just an unnecessarily complicated version of GetChildren()?

:sweat:
No.

It allows you to tag instances and enact functions, events, and changes on all of them instantly.

it wouldn’t matter for this case since they’re all under the parent object

1 Like

Now that I’m noticing, you are telling me to use a service that gets groups of parts from one ancestor. This is both useless when talking about a model that already exists with barely any children (even if there were too many, getchildren() would do the job), and when talking about colours. I don’t understand what I am going to do with CollectionService while I am trying to exclude colours from a randomizer. I don’t want to rewrite my script. I want to change the colours in it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.