Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't my BrickColor be random?

local Owner
local colors = {"Medium stone grey","Sea green","Really red"}

while true do
	Owner = script.Parent.Parent.owner
	if Owner.Value ~= nil then
	local original = script.Parent.Party1
    local copy = original:Clone()
    copy.Parent = script.Parent.Parent.Parties
	copy.Transparency = 0
	copy.CanCollide = true
	copy.Anchored = false
    copy.Position = Vector3.new(129.5, 8.5, -16.25)
	copy.BrickColor = BrickColor.new(colors[math.random(1, 3)])
	wait(1)
	end
	wait()
end

6 comments

0

do you want a whole spectrum of colors or just those three?

0

you can just do Brickcolor.Random()

0

just those 3

0

idk if that's the correct capitalization :P

0

It is

0

setting the Parent first might be causing lag

2 answers

Hi!

It was expecting a BrickColor value, but you gave it a String value!

Simple fix!

copy.BrickColor = BrickColor.new(colors[math.random(1, 3)]) --This is what your BrickColor line should look like

What you were essentially doing:

copy.BrickColor = "ColorHere" --Incorrect

What its doing now:

copy.BrickColor = BrickColor.new("BrickColorHere") --Correct

10 comments

0

didn't work...

0

Color3.fromRGB is guaranteed to work, sometimes BrickColor doesn't accept strings

0

I tested it in Studio...It is working as advertised.

0

ahem if strings don't work use numbers

0

No need for that. The code I posted works perfectly fine(Just as much as using Color3.fromRGB would). 

0

I don't get it. It doesn't work

0

Are you receiving any errors in output?

0

DERR. I figured it out, I had a texture on it, it was a meshpart

0

you could just use Brickcolor.Random()

This discussion is preserved as it was. New answers, comments, and votes are closed.