Today I learned about ObjectValues, which is used to store an Instance (as a reference). Like all other Values, they have a Value property, which returns the Instance stored. This is fine when you do things like changing the Parent of the stored instance, but what about properties normally not inside Instance (say Color)?
local object = --[[Path leading to ObjectValue]]
object.Value.Position = Vector3.new(0,10,0) -- ?
-- Position is not a property of 'Instance',
-- but rather a property of its derived classes, such as 'BasePart'
How would Luau know what type the value stores, or would I have to downcast (cast from reference of base class to reference of derived class) the Instance returned by object.Value
to a BasePart to then use it? If not (that is, Luau does the downcast implicitly), then how would it know the type of the object stored (since ObjectValue
s only store Instance
s, it would only know it stores an Instance (or nil, if it’s not assigned to anything), but what type derived from Instance?)?