Instance Attributes

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:

  • Attributes can be created, edited, and deleted directly within Studio's Properties window.
  • Attributes and their values are saved with your place and assets.
  • Value changes can be viewed in real time and are replicated so that clients can access them immediately.

Specific examples of attribute usage include:

Weapons with attributes such as damage, fire rate, and reload time
Vehicle tuning like acceleration and top speed
Additional package or asset metadata such as description, version, and author

Supported Types

You can store the following types/values in attributes:

Studio Usage

New attributes can be created and modified in Studio as follows:

  1. Select the instance, scroll to the bottom of the Properties window, and click Add Attribute.

  2. In the popup window, enter the attribute Name, select its Type, and click Save.

  3. The new attribute will appear with a default value that you can change just like any other property.

  4. If necessary, you can rename or delete an attribute by clicking the gear icon.


Attributes can also be created and controlled through scripts.

Creating/Modifying Attributes

To create an attribute or modify an existing attribute's value, call Instance:SetAttribute() with a name and value.

Create or Modify Attribute

local weapon = script.Parent
-- Create an attribute
weapon:SetAttribute("ReloadTime", 3)

Getting Attribute Values

To get the value of one existing attribute, call Instance:GetAttribute() on the instance.

Get Attribute Value

local weapon = script.Parent
-- Create an attribute
weapon:SetAttribute("ReloadTime", 3)
-- Get current attribute value
local reloadTimeValue = weapon:GetAttribute("ReloadTime")

Similarly, you can get all attributes of an instance by calling Instance:GetAttributes(). This returns a dictionary of string/variant pairs representing each attribute.

Get All Attributes

local weapon = script.Parent
-- Create attributes
weapon:SetAttribute("ReloadTime", 3)
weapon:SetAttribute("FireSound", "rbxassetid://3821795742")
-- Get all instance attributes
local weaponAttributes = weapon:GetAttributes()
for name, value in pairs(weaponAttributes) do
print(name, value)

Deleting Attributes

To delete an attribute, call Instance:SetAttribute() with a value of nil.

Delete Attribute

local weapon = script.Parent
-- Delete an existing attribute
weapon:SetAttribute("ReloadTime", nil)

Detecting Attribute Changes

To listen for value changes on one or more attributes:

Listen for Change on Attribute(s)

local weapon = script.Parent
--- Listen for one specific attribute change
-- Listen for any attribute change on the instance
print(attributeName, weapon:GetAttribute(attributeName))