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 give me 2 diffrent colors randomly?(SOLVED!)

Asked by
Ete999 0
10 years ago
local CD = script.Parent -- Where is the Click Detector?
function onMouseClick(player)--He is clicking!
    wait(2)
    Workspace.BoyGirl.BrickColor = BrickColor.new(math.random(21,23))-- Red or blue?
    wait(2)
    Workspace.BoyGirl.BrickColor = BrickColor.new(194) -- Grey!

end

CD.MouseClick:connect(onMouseClick)-- For the connect!

I have tried to make a brick that will either show Red or blue, however i can't make it work. do anyone of you have a solution how to make a brick that will show me Red or Blue whenever i click it?

(As you might see, i want the Brick to return to its Colour, Grey after it has shown either Red or Blue)

any answers are helpfull! Thank you in advance.

1 answer

Log in to vote
0
Answered by
Damo999 182
10 years ago

Firstly i have made the script smaller but you had two problems you did not put a click detector inside of the part, second your had this line CD.MouseClick:connect(onMouseClick) it should not be this but the connection line should be this CD.ClickDetector.MouseClick:connect(onMouseClick)

Also this line Workspace.BoyGirl.BrickColor = BrickColor.new(math.random(21,23)) wouldn't just display red or blue it would also display a third color which is a pinkish type color.

Here is your original script

local CD = script.Parent -- Where is the Click Detector?
function onMouseClick(player)--He is clicking!
    wait(2)
    Workspace.BoyGirl.BrickColor = BrickColor.new(math.random(21,23))-- Red or blue?
    wait(2)
    Workspace.BoyGirl.BrickColor = BrickColor.new(194) -- Grey!

end

CD.MouseClick:connect(onMouseClick)-- For the connect!

here is the fixed script.

local BoyGirl = script.Parent
CD = Instance.new("ClickDetector",BoyGirl)

BoyGirl.ClickDetector.MouseClick:connect(function()
    wait(2)
    Workspace.BoyGirl.BrickColor = BrickColor.new(math.random(21,23))
    wait(2)
    Workspace.BoyGirl.BrickColor = BrickColor.new(194) 
end)
Ad

Answer this question