I'm trying to check the BrickColor of a part and all I can think of to check the Brickcolor is
if HoleA.BrickColor.red then print "hello world" end
*HoleA is a variable of the part I want to check
The error I get when Is "red is not a valid member of BrickColor"
How do I check the BrickColor of a part
Use if ... == ... then ... end
for check arguments.
You can see of Conditional Statements here in wiki: Conditional Statements in Lua
Conditional statements allow your script to perform specific actions when specific conditions are met.
Here is a example image: Image
if code script:
if 2 + 3 == 5 then print("two plus three is five") end
There is also the "else"
else code example:
if 10 > 100 then print("10 is greater than 100") else print("10 is less than 100") end
There are also things with "elseif" here's an example:
elseif code example:
if 10 > 100 then print("10 is greater than 100") elseif 10 > 50 then print("10 is greater than 50") elseif 10 < 100 then print("10 is less than 100") end
All of the above is on the wiki
It is advisable to read the wiki, because there are many other examples.
How to detect color?
local brick = game.Workspace.Part -- Brick location. if brick.BrickColor == BrickColor.new("Alder") then -- Check if brick color is Alder if is Color in Alder then... print("Hello") -- print hello in output end
How to set color?
local brick = game.Workspace.Part -- Brick location. brick.BrickColor = BrickColor.new("Alder") -- Set color to brick.
you can see of BrickColor Code's in wiki:
You can see of BrickColor in wiki:
Hope it helped :)
You could do it like this
local HoleA= game.Workspace.Part HoleA.BrickColor = BrickColor.new("Alder") if HoleA.BrickColor == BrickColor.new("Alder") then print("Subscribe to Pewdiepie") end