Component views¶
Indexing entity.<Component> returns a view of one component on the entity,
or nil when the entity does not have it. A view reads and writes only the
fields of its own component.
-- Server script in a part.
print(self.Light) -- prints nil
self:Add(Component.Light)
local light = self.Light
if light then
light.Intensity = 2
print(light.Intensity) -- prints 2
print(light.Range)
end
A view never adds its component, and using it after the component was removed is an error. A tag component has no view.
A view names a color ...Color, as the entity properties do, such as
TextColor in the UITextStyle view. The Box view names its layout
Position and Size.
Some components have fields only in their view, such as the
particle components and CharacterAbilities.