PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

GetAttributeChangedSignal

This function returns an event that behaves exactly like the Changed event, except that the event only fires when the given attribute changes. It’s generally a good idea to use this method instead of a connection to Changed with a function that checks the attribute name. Subsequent calls to this method on the same object with the same attribute name return the same event.

It is similar to Instance/GetPropertyChangedSignal but for attributes.

For example, the following code snippet will return a signal that fires the function Instance/AttributeChanged when the instance’s InitialPosition attribute changes. Note that this code sample does not define Instance:

local function attributeChanged()
    print(“Attribute changed”)
end

instance:GetAttributeChangedSignal("InitialPosition"):Connect(attributeChanged)

See also

  • Instance/SetAttribute, sets the attribute with the given name to the given value
  • 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

Parameters

Name Type Default Description

The name of the specified attribute for which the change signal is being returned

Returns

Return Type Summary

An event that fires when the given attribute changes