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

How would I make this change to a certain brick color?

Asked by 10 years ago

Alright so I wanted this bright to change to 4 certain colors when I click the brick. This was my code, but it didn't work. Could you please help me out? Thanks!


local Brick = script.Parent function onClick() Brick.BrickColor = BrickColor.new("Bright orange","Bright red","Bright blue","Lime green") end Brick.ClickDetector.MouseClick:connect(onClick)

2 answers

Log in to vote
0
Answered by 10 years ago

You would most likely have to do this:

local Brick = script.Parent 
function onClick() 
Brick.BrickColor = BrickColor.new("Bright orange")
wait(1)
Brick.BrickColor = BrickColor.new("Bright red")
wait(1)
Brick.BrickColor = BrickColor.new("Bright blue")
wait(1)
Brick.BrickColor = BrickColor.new("Lime green")
end
Brick.ClickDetector.MouseClick:connect(onClick)

0
Do you know how to make it like select the color randomly though? Y0UNGK1NG 0 — 10y
0
Math.random TheUniPiggy 77 — 8y
Ad
Log in to vote
0
Answered by 10 years ago

For it to go randomly, do this:

local Brick = script.Parent

function onClick()
local random = math.random(1, 4)

if random == 1 then
Brick.BrickColor = BrickColor.new("Bright orange")

elseif random == 2 then
Brick.BrickColor = BrickColor.new("Bright red")

elseif random == 3 then
Brick.BrickColor = BrickColor.new("Bright blue")

elseif random == 4 then
Brick.BrickColor = BrickColor.new("Lime green")

end

Brick.ClickDetector.MouseClick:connect(onClick)

Answer this question