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

How do I Make A Brick A Random Color?

I Wanna make A Baseplate that turns A Random Color so I Did this

B = math.random(1,2)
if B == 2 then
	local b = Script.Parent
	b.BrickColor = BrickColor.new("Pastel Blue")
else do
	local b = Script.Parent
	b.BrickColor = BrickColor.new("Bright Green")
end
	end

Its not Working Please Help

4 answers

✓ Accepted answer

You could do BrickColor.Random()

It gives the brick a random BrickColor Black, Red, Blue, anything that you can normally get it will give you a random brickcolor.

But with your script if you just want the two brickcolors;

C = math.random(1,2) --Don't want similar tags, it matched too closely with the brick tags.
if C == 2 then
    local b = script.Parent --Lua is case sensitive, it's script, not Script.
    b.BrickColor = BrickColor.new("Pastel blue") --BrickColors are Case Sensitive as well.
else --You only need do's in loops, not in if then statements.
    local b = script.Parent --Lua is case sensitive.
    b.BrickColor = BrickColor.new("Bright green") --Same here.
end
end

3 comments

0

Bebee2 supports. Example would be "script.Parent.BrickColor = BrickColor.random()"

0

@theamazemanII, M39a9am3R did change this, but didn't point it out explicitly - there should not be a "do" right after an "else" statement.

0

Oops, did I? I'll fix it real quick.

The "b" on the first 2 lines needs to NOT be a capital. Lowercase. If that dosent work then contact me and I'll try creating a script for it

This is all you need:

script.Parent.BrickColor = BrickColor.random()
Game.Workspace.Part.Brickcolor = Brickcolor.Random()

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