BrickColor.Random went wrong

Hello. Attempting to script a color randomizer for houses, I got this tomfoolery.


It’s also coloring it the colors I didn’t list.
Script:

local colors = {
	"Pastel Blue",
	"Artichoke",
	"Dark stone grey",
	"Salmon",
	"Slime green",
	"Storm blue",
	"Crimson",
	"Gold",
	"Neon orange",
	"Fawn brown",
	"Pearl",
	"Medium stone grey"
}

for _, colorparts in pairs(script.Parent:GetChildren()) do
	if colorparts.Name == "Color" and colorparts:IsA("BasePart") then
	colorparts.BrickColor = BrickColor.random(colors)
	end
end

Hello, if you want to change the color of all parts then you should use the following script:

local colors = {
	"Pastel Blue",
	"Artichoke",
	"Dark stone grey",
	"Salmon",
	"Slime green",
	"Storm blue",
	"Crimson",
	"Gold",
	"Neon orange",
	"Fawn brown",
	"Pearl",
	"Medium stone grey"
}

local Color = BrickColor.random(colors)

for _, colorparts in pairs(script.Parent:GetChildren()) do
	if colorparts.Name == "Color" and colorparts:IsA("BasePart") then
		colorparts.BrickColor = Color
	end
end

I got a error:


edit: ok nvm @VideoBlogsPro5 's solution worked, but still not getting the color i listed

Their script should work… elaborate more on how you arent getting the color u listed

I listed certain colors in the script the house should be colored with.
Unfortunately, it is coloring with the colors I did not list.

1 Like

Ah, I just realized. BrickColor.random isn’t even suppose to take in an argument. It just outputs a random BrickColor, any possible one. So, we need to create our own list, like this:

local brickcolor = {
	BrickColor.new("Pastel Blue"),
	BrickColor.new("Artichoke"),
	BrickColor.new("Dark stone grey"),
	BrickColor.new("Salmon"),
	BrickColor.new("Slime green"),
	BrickColor.new("Storm blue"),
	BrickColor.new("Crimson"),
	BrickColor.new("Gold"),
	BrickColor.new("Neon orange"),
	BrickColor.new("Fawn brown"),
	BrickColor.new("Pearl"),
	BrickColor.new("Medium stone grey")
}

local colorlist = brickcolors[math.random(#brickcolors)]

for _, colorparts in pairs(script.Parent:GetChildren()) do
	if colorparts.Name == "Color" and colorparts:IsA("BasePart") then
		colorparts.BrickColor = colorlist
	end
end
1 Like

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