BrickColor (Property): Difference between revisions
From Goodblox Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{CatUp|Properties}} | {{CatUp|Properties}} | ||
{{Property| | {{Property| | ||
name = BrickColor | name = BrickColor | ||
| Line 6: | Line 5: | ||
|description = Stores the color of the object | |description = Stores the color of the object | ||
|object = [[GBX.lua.BasePart (Object)|BasePart]]|}} | |object = [[GBX.lua.BasePart (Object)|BasePart]]|}} | ||
==Example== | ==Example== | ||
Latest revision as of 21:27, 23 September 2021
| Property | |
|---|---|
| Name | BrickColor |
| Property | BrickColor BrickColor |
| Description: | Stores the color of the object |
| In Object: | BasePart |
Example
--[[ NOTE: To compare the property BrickColor with the name of a color,
you need to use tostring() to convert BrickColor to a string. Even though
print(otherPart.Parent.Torso.BrickColor) does return the name of the color,
you cannot use it by itself in a comparison. ]]--
local 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 tostring(otherPart.Parent.Torso.BrickColor) == "Bright red" then -- This will match
print("Match occurred")
end
end