BrickColor (Property): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Oysi93
Gave it more of a correct example. =)
>Oysi93
Gave it more of a correct example. =)
(No difference)

Revision as of 11:31, 29 August 2010

For an explanation of BrickColor, click here

BrickColor
Property BrickColor BrickColor
Description Stores the color of the object.
Member of [[RBX.lua.Flagstand, Part, Seat, SpawnLocation (Object)|Flagstand, Part, Seat, SpawnLocation]]


Comparison

To compare the property BrickColor with the name of a color, you need to index the 'Name' property of the BrickColor. That will convert the BrickColor to a string. Even though this script below does output the name of the color, you cannot compare a color and a string.

print(otherPart.Parent.Torso.BrickColor)

Example

function onTouched(otherPart)
    print(otherPart.Parent.Torso.BrickColor) -- Outputs the name of the color 
    if otherPart.Parent.Torso.BrickColor == "Bright red" then -- This will not match
        print("Never gets executed")
    elseif otherPart.Parent.Torso.BrickColor.Name == "Bright red" then -- This will match
        print("Match occurred")
    end
end

See Also

BrickColor Codes