Need help with random color generator. [PLEASE HELP]

Hello! So I recently got help with a script that makes any blocks in a folder turn neon and become a random color.

Before:


After:

It changes color every time:

Now I have realized there are a few things I wan’t to do, but I don’t know how to do, only basic parts.

A. I wanna make it a specific color pallete, not every brick color.

B. Some of the colors are over-ly neon, is there a way to turn it down?

If you could give an explanation with an answer, that would be wonderful, or if you could direct me to another information source, that would also be ok. Here is my script right now:

for i, v in pairs(workspace.Folder:GetChildren()) do
    v.BrickColor = BrickColor.random()
	v.Material = "Neon"
end

Thank you :slight_smile:

2 Likes

Simple make a table of the select brickColors:

local Colors = {BrickColor.new(), BrickColor.new(), etc}

Then use random to loop through them:

for i, v in pairs(workspace.Folder:GetChildren()) do
    v.BrickColor = Colors[math.random(#Colors)
	v.Material = "Neon"
end

The code would look like this:

local Colors = {BrickColor.new(), BrickColor.new(), etc}

for i, v in pairs(workspace.Folder:GetChildren()) do
    v.BrickColor = Colors[math.random(#Colors)
	v.Material = "Neon"
end

Basically, what this code does is you chose your colour pallet, then you would put those colours in a table. Then, in the for loop, you would randomly pick a colour from the table and set the property.


#Colors just tells the computer how many things are in the table.

4 Likes

What does the

do? Thanks so much.

Use tables and math.random

        ''''
              local colors = {"Hot pink", "Really red", "Toothpaste", "New Yeller", "Lime green"} -- insert your colors here
              local part = script.Parent -- path to the part

              while true do -- loops
                 local ChosenColor = math.random(1, #colors) -- chooses color
                 tile.BrickColor = BrickColor.new(colors[ChosenColor]) -- changes the brickColor of the part
                 wait(1)
              end
                  

              '''
1 Like

It means number of colors. The “#” means number

?

30303030303030303030charss