[DEPRECATED] ezAttribute - a simple fix for a big problem with getting and setting attributes

DEPRECATED! Refer to this post instead: EasyAttribute

If you’re like me then you probably were pretty excited when you found out the long awaited Attributes were out and went to go try them out. You went to the wiki and implemented it in a test place, only to realize the agonizing pitfall.

Every time you want to get an attribute, you have to use :GetAttribute, and the same with setting it (but with :SetAttribute ). Today, this ends.

ezAttribute
I’m not gonna lie here or say that ezAttribute is anything stellar, or really complicated, or is a big load off development: it’s incredibly simple. What’s important is that it does the job perfectly, letting you use attributes just like you would a normal Value Object (it’s just a wrapper for attributes).

To use it, require the module with require(6506183427) and save it to a variable.
Then, invoke the variable with an Instance and Attribute name and save that to a variable as well.

local ezAttribute = require(6506183427);
local myAttribute = ezAttribute(workspace, "SecretWord");

Keep in mind that doing this has not yet created the attribute, it will be created when you set the value like so:

myAttribute.Value = "Cheese";

And voila! You’ve just used ezAttribute to create and set an attribute. You can fetch it just as easily.

print(myAttribute.Value); -- Cheese

I’ll probably do some updates for this in the future, support for constant attributes comes to mind, where it won’t let you change it to anything that isn’t its original DataType.

Let me know what you’d like to see added!

3 Likes