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

What Is Wrong With My Button Part Color Changer Script?

Asked by
tanzane 100
9 years ago
A = game.workspace.Butt2
script.Parent.Touched:connect(function(Color)
if A.BrickColor == "Medium Stone Grey" then
print("Working")
game.Workspace.Butt2.BrickColor = BrickColor.new("Really Red")
elseif A.BrickColor == "Really Red" then
    A.BrickColor = BrickColor.new("Really Blue")
elseif A.BrickColor == "Really Blue" then
    A.BrickColor = BrickColor.new("Really Red")
end 
end)

My situation is I have this line of code inside a part, that is a button. I have another part a few studs away from the button. I just don't understand why it isn't working. I assumed that it might have been the fact that I stuck the code into an anonymous function, but It seemed to be that It didn't work, unless I failed to make a regular function as well.

Did I mess up on a line or something?

1 answer

Log in to vote
0
Answered by 9 years ago

When checking to see if something is a BrickColor, you still need to use BrickColor.new(), because BrickColor values are not strings.

Also, BrickColor values only have the first letter capitalised, like so:

BrickColor.new("Medium stone grey")
0
Oh wow how could I've made such a mistake, thanks :) tanzane 100 — 9y
0
np :P TheDeadlyPanther 2460 — 9y
Ad

Answer this question