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

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

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

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)

2 comments

0

Do you know how to make it like select the color randomly though?

0

Math.random

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)

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