EasyAttribute - An easy-to-use wrapper for Roblox's new Attributes

This is based on ezAttribute (my previous version), and is a wrapper for Roblox Attributes getter and setter functions. Originally I wasn’t planning on supporting this too heavily but now I’ve got some competition. This will be the definitive thread for EasyAttribute.

Here’s how it works:
As oppose to using GetAttribute and SetAttribute, EasyAttribute lets you fetch and edit them like this.

local EasyAttribute = require(6506183427);
local myWorkspace = EasyAttribute(workspace);

Now you can simply index or set anything in this table to set or get an attribute.

myWorkspace.Number = 100;


And get it by referencing the same index.



Additionally, you can use :Increment on number attributes to add the specified amount to them, or 1 if you didn’t specify.

myWorkspace:Increment("Number", 10);


The coolest feature is support for strong-typed attributes, attributes that won’t let you change them to a value that isn’t there initial type.

myWorkspace.Number = "Cheese";


To make the above impossible, we’ll use :SetType with our attribute and the type. true is dynamic (it can be anything) and false is strong (it won’t let you change it to something of a type it currently isn’t).

myWorkspace:SetType("Number", false);
myWorkspace.Number = "Cheese";


Last but not least, indexing Raw will return the actual Instance, which is useful if you want to reference the Instance in a function that has only been passed the EasyAttribute object.



And that’s all! I may add more features if I think of any in the future, so definitely request what you would like to see added.



I can’t view at the source code right now, but I would just remind you to make it so that people can’t write to .Raw as a attribute! ( And also always prioritize raw over as attributes ), that is probably already a thing so yeah.

I would have preferred a function method to do something like :GetRaw() or something, since it would work better with people’s creations!