PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

BrickColor

BasePart

BrickColor

The BrickColor property determines the color of a part. If the part has a /BasePart/Material, this also determines the color used when rendering the material texture. For more control over the color, the /BasePart/Color property can be used (it is a Color3 variant of this property). If Color set, this property will use the closest BrickColor.

Other visual properties of a part are determined by /BasePart/Transparency and /BasePart/Reflectance.


Code Samples


Part Anchored Toggle

This code sample will allow a part to be clicked to toggle its anchored property. When toggled, the visual appearance of the part is updated (red means anchored, yellow means free).

local part = script.Parent

-- Create a ClickDetector so we can tell when the part is clicked 
local cd = Instance.new("ClickDetector", part)

-- This function updates how the part looks based on its Anchored state
local function updateVisuals()
	if part.Anchored then
		-- When the part is anchored...
		part.BrickColor = BrickColor.new("Bright red")
		part.Material = Enum.Material.DiamondPlate
	else
		-- When the part is unanchored...
		part.BrickColor = BrickColor.new("Bright yellow")
		part.Material = Enum.Material.Wood
	end
end

local function onToggle()
	-- Toggle the anchored property
	part.Anchored = not part.Anchored
	
	-- Update visual state of the brick
	updateVisuals()
end

-- Update, then start listening for clicks
updateVisuals()
cd.MouseClick:connect(onToggle)