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

Why will my brick not change colors?

Asked by 9 years ago

The output says something about BrickColor needing to be a string or something. Not really sure what it means.

local B1 = workspace.Deathrun.Button1
local walk = workspace.Deathrun.walk1
local walk2 = workspace.Deathrun.walk2
function onClick()
    B1.BrickColor = 'Really red'
    walk2.CanCollide = false
    walk.CanCollide = false
    print 'off'
    wait(10)
    print 'on'
    walk2.CanCollide = true
    walk.CanCollide = true
    wait(7)
    B1.BrickColor = 'Lime green'
end
B1.ClickDetector.MouseClick:connect(onClick)

3 answers

Log in to vote
0
Answered by
Marios2 360 Moderation Voter
9 years ago

Although it might look like it, the text you see at the BrickColor properties in Studio are not strings, but BrickColor values. The proper way to create a BrickColor value is through...

BrickColor.new()

This is the function which gives the Parts color. There are 3 (4) types of values that this function accepts, but we'll stick to the string. All you need to do for the string part is to insert the string within the parentheses, like this:

BrickColor.new('Really red')

Therefore, to apply the "Really red" color, you use:

B1.BrickColor = BrickColor.new('Really red')

The exact same method is used for "Lime green". I recommend you take a look at the following Roblox Wiki pages (which will be more useful than what you might think)

More than you ever wanted to know about BrickColor

A full list of available BrickColors (There are more than you can choose in the palette)

Ad
Log in to vote
0
Answered by 9 years ago
local B1 = workspace.Deathrun.Button1
local walk = workspace.Deathrun.walk1
local walk2 = workspace.Deathrun.walk2
function onClick()
    B1.BrickColor=BrickColor.new'Lime green'
    walk2.CanCollide = false
    walk.CanCollide = false
    print 'off'
    wait(10)
    print 'on'
    walk2.CanCollide = true
    walk.CanCollide = true
    wait(7)
    B1.BrickColor=BrickColor.new'Really red'
end
--We have a part so we get the new value by equaling it to ".new"
B1.ClickDetector.MouseClick:connect(onClick)

If this helped please accept my answer and upvote if possible thanks it's much appreciated.

0
This did not work. It says parenthesis where needed in areas and that textcolor3 is not a valid member of 'part' Conmmander 479 — 9y
0
Explain. A plain answer only goes as far as fixing the script, and not everyone learns easily. Marios2 360 — 9y
0
This could work without parenthesis. legomaster38 39 — 9y
0
This could be done in two different ways. One with the double strings and parenthesis B1.BrickColor=BrickColor.new("Really red") or one without the double strings and parenthesis B1.BrickColor=BrickColor.new'Really red' You can check out a list full of brickcolor codes for roblox parts, Here at: http://wiki.roblox.com/index.php?title=BrickColor_codes legomaster38 39 — 9y
Log in to vote
0
Answered by 9 years ago
local B1 = workspace.Deathrun.Button1
local walk = workspace.Deathrun.walk1

local walk2 = workspace.Deathrun.walk2

function onClick()

B1.BrickColor = BrickColor.new('Really red')

walk2.CanCollide = false
    walk.CanCollide = false

print("Off")
    wait(10)
print ("On")

 walk2.CanCollide = true
    walk.CanCollide = true

wait(7)
    B1.BrickColor = BrickColor.new('Lime green')

end

B1.ClickDetector.MouseClick:connect(onClick)

0
Please give reasons to why your code works when you're answering a question and not just give them a script. alphawolvess 1784 — 9y

Answer this question