Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I Make A Brick A Random Color?

Asked by 10 years ago

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

Log in to vote
5
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

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

0
Bebee2 supports. Example would be "script.Parent.BrickColor = BrickColor.random()" Bebee2 195 — 10y
0
@theamazemanII, M39a9am3R did change this, but didn't point it out explicitly - there should not be a "do" right after an "else" statement. duckwit 1404 — 10y
0
Oops, did I? I'll fix it real quick. M39a9am3R 3210 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

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

Log in to vote
0
Answered by 10 years ago

This is all you need:

script.Parent.BrickColor = BrickColor.random()
Log in to vote
0
Answered by 9 years ago
Game.Workspace.Part.Brickcolor = Brickcolor.Random()

Answer this question