How do I make the color of my part random but out of a select few colors

I am trying to make it so my part changes colors, I understand how to do this but instead of the color being random I want it to randomly pick from a selection of colors.
BrickColor = BrickColor.random()
this is what im using right now and its working fine but its making the colors ugly, I don’t want like brown or black or white or anything just vibrant colors.
How do I make it so the code picks randomly from a few colors that I actually like?

you can use this script

local colors = {}--put all the colors you want in this table
Color = Colors[math.random(#colors)]

Make a table of your own selected colours and choose a random one from that table.

local niceColours = {
	Color3.new(1,0,0),
	Color3.new(0,1,0),
	Color3.new(0,0,1),
	Color3.new(1,1,0)	--- etc
};

local randomColour = niceColours[math.random(1,#niceColours)];
game.Workspace.Baseplate.Color = randomColour;
1 Like

If by “vibrant colors” you mean the top colors of the color-picking image that aren’t saturated or dark, for example, the colors red, pink, purple, blue, cyan, green, and yellow then you can use the H, S, V(hue, saturation, value) color scheme with fixed max values for saturation and value(value is the color brightness) and randomize the hue which represents the color(for example if it’s red or blue). Here’s a function that randomly picks such a color:

function GetRandomVibrantColor(): Color3 
	return Color3.fromHSV(math.random(), 1, 1)
end

local color = GetRandomVibrantColor()
--this is just done for visualization, you can just do part.Color = color to apply it to something
print(color.R*255, color.G*255, color.B*255)
1 Like