Attributes allow you to customize instances with your own data. They are similar to built-in object properties, but you can create and modify your own attributes for any instance. Key features include:
- Create, edit, and delete attributes directly within Studio’s Properties window.
- Attributes and their values are saved with your place and assets.
- Attributes and their value changes are replicated so clients can access them immediately.
- Attribute changes can be viewed in real time.
Specific examples of attribute usage include:
Currently, you can store the following types/values in attributes:
New attributes can be created and modified in Studio as follows:
- Select the instance, scroll to the bottom of the Properties window, and click Add Attribute.
- In the popup window, enter the attribute Name, select its Type (string, number,
datatype/Color3, etc.), and click Save.
- The new attribute will appear with a default value that you can change just like any other property.
- If necessary, you can rename or delete an attribute by clicking the gear icon.
Attributes can also be created and controlled through scripts.
To create an attribute or modify an existing attribute’s value, call
Instance/SetAttribute with a name and value.
Getting Attribute Values
To get the value of one existing attribute, call
Instance/GetAttribute on the instance.
Similarly, you can get all attributes of an instance by calling
Instance/GetAttributes — this returns a dictionary of string/variant pairs for each attribute.
To delete an attribute, call
Instance/SetAttribute with a value of
Detecting Attribute Changes
To listen for value changes on one or more attributes, connect either
Instance/GetAttributeChangedSignal (specific attribute) or
Instance/AttributeChanged (any instance attribute).