How do you get the name of a attribute?

Hey!
I’m making a system that required putting attributes into values blah blah blah. How would I get a attribute’s name? I can’t seem to find it documented anywhere.

1 Like

You can use :GetAttributes for this.

That doesn’t return the name, only the value, It’s a table not dictionary.

yes, it does get the name of an attribute.

local atts = Instance:GetAttributes()

for i,v in pairs(atts) do
    print(i..": "..v)
end

i is always the index of it.

1 Like

A dictionary is a table, likewise an array is a table. In this case “:GetAttributes()” returns a dictionary of attributes of the instance it is called on/through. This dictionary can be iterated over with the pairs() iterator.

for AttName, AttValue in pairs(Instance:GetAttributes()) do
	print("Attribute: "..AttName, "Value:"..AttValue)
end

The keys/fields of the returned dictionary are the names of each attribute and the values assigned/associated with those keys/fields are the values of each corresponding attribute.

2 Likes