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

How do i make a brick change colour? [closed]

Asked by 9 years ago
local brick = Workspace.Brick 

function onTouch(part) 
    brick.Transparency = 1
    wait(1) 
    brick.Transparency = 0 
end 

brick.Touched:connect(onTouch)

What am i doing wrong? and what do i do to make it work?

0
I am also very. VERY new to scripting. HuzenLoo 10 — 9y
0
You're changing the Transparency, which is totally different from changing a brick's BrickColor. http://wiki.roblox.com/index.php?title=API:Class/BasePart/Transparency http://wiki.roblox.com/index.php?title=API:Class/BasePart/BrickColor Redbullusa 1580 — 9y

Locked by Leamir

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

6 answers

Log in to vote
0
Answered by 9 years ago
local brick = Workspace.Brick

function onTouch(part) 
    brick.Transparency = 1 -- You're changing the transparency of the brick, which is different from 
changing the color of the brick.
    brick.Color = BrickColor.new("Bright red")  -- Using this will change the brickcolor. If you would like to learn more about these things, please reference these links (after script)
    wait(1) 
    brick.Transparency = 0 
end 

brick.Touched:connect(onTouch)

http://wiki.roblox.com/index.php?title=API:Class/BasePart/Transparency http://wiki.roblox.com/index.php?title=API:BrickColor

Ad
Log in to vote
0
Answered by
bloxxyz 274 Moderation Voter
9 years ago

BrickColor doesn't go by numbers, it's by its name in Explorer. For example, there is a color called "Really red", if you want a brick to be red, you would input this script:

game.Workspace.BrickNameHere.BrickColor = BrickColor.new("Really red") 

When inputted, the brick will turn red. Just highlight the color in paint bucket with your mouse and it will tell you what to put in the strings, or quotation marks "".

If you want to make your script example bright blue, you would do the following:

local brick = Workspace.Brick

function onTouch(part)
brick.BrickColor = BrickColor.new("Bright blue") 
end
brick.Touched:connect(onTouch)

What you did is Transparency, which basically determines whether the brick is opaque, or clear like a window.

Log in to vote
0
Answered by
Nosteal 50
9 years ago

Alright, so you are accessing the Transparency, not BrickColor. Here's how it should be:

brick = game.Workspace.Part
function onTouch()
    brick.BrickColor = BrickColor.new("Lime green") --You have to spell it correctly.
end
brick.Touched:connect(onTouch)

You gotta be careful with the capitals... Here's how it should NOT be:

brick = game.Workspace.Part
function onTouch()
    brick.BrickColor = BrickColor.new("Lime Green")
end
brick.Touched:connect(onTouch)

That would display an error because the correct color is Lime green, not Lime Green. And if you want it to go back to a certain color(We will use Medium stone grey as an example) use this:

brick = game.Workspace.Part
function onTouch()
    brick.BrickColor = BrickColor.new("Lime green")
    wait(1) -- This can be any number that you want*.
    brick.BrickColor = BrickColor.new("Medium stone grey")
end
brick.Touched:connect(onTouch)
--* = Remember that the script will wait for the number that you set it to before setting the color to medium stone grey

Oh and also, brick = game.Workspace.Brick is incorrect unless you renamed the part into Brick. PS: You gotta put the script INSIDE the part.

Log in to vote
0
Answered by 4 years ago
local brick = workspace.Brick

function onTouched()
    brick.Transparency = 1
    wait(1)
    brick.Transparency = 0
    brick.BrickColor = BrickColor.new('Really red')
end

brick.Touched:Connect(onTouched)

Log in to vote
0
Answered by 4 years ago

I used a variable to hold the amount of time you want to wait, so that you don't have to look for the line that the wait function is on. :)

local brick = workspace.Brick
local timetowait = 1
function ontouch(part)
    brick.Transparency = 1
    brick.BrickColor = BrickColor.new("Blue") -- You can change the color to what ever you want.
    wait(timetowait)
    brick.Transparency = 0
end
Log in to vote
-1
Answered by 9 years ago
local brick = workspace.Brick

script.Parent.Touched:connect(function(part)
brick.Transparency = 1
brick.Color = Color3.new(math.random())
wait(1)
brick.Transparency = 0

end)

Accept Answer Please