Collapse Sidebar


This function sets the attribute with the given name to the given value. If the value given is nil, then the attribute will be removed (since nil is returned by default).

For example, the following code snippet will set the instance’s InitialPosition attribute to DataType/Vector3|Vector3.new(0, 0, 0). Note that this code sample does not define Instance:

instance:SetAttribute("InitialPosition", Vector3.new(0, 0, 0))


Naming requirements and restrictions:

  • Names must only use alphanumeric characters and underscore
  • No spaces or unique symbols are allowed
  • Strings must be 100 characters or less
  • Names are not allowed to start with RBX unless the caller is a Roblox core-script (reserved for Roblox)

When attempting to set an attribute to an unsupported type, an error will be thrown.

See also

  • Instance/GetAttribute, returns the attribute which has been assigned to the given name
  • Instance/GetAttributes, returns a dictionary of string → variant pairs for each of the instance’s attributes
  • Instance/AttributeChanged, fires whenever an attribute is changed on the instance
  • Instance/GetAttributeChangedSignal, returns an event that fires when the given attribute changes


Name Type Default Description

The name of the attribute being set

The value that the specified attribute is being set to


Return Type Summary

No return