Index Attributes

Have you ever wanted to use attributes without using getter and setter functions like some sort of low-level java peasant? Well you’re in luck!

This post was inspired by another community resource. This is basically that, but better.

You can use it like this:

MakeAttributesIndexable = require(script.IndexAttributes)
workspaceAttributes = MakeAttributesIndexable(workspace)

workspaceAttributes.test = "hey there!"


This is the equivalent of

workspace:SetAttribute("test","hey there!")


The module itself is very simple, but some people might not know enough about metatables to know how to do this, so I thought I’d post this as a resource.


very cool i love it, personally I am not the scripter, so I don’t know whats the advantage of this to getter and setter functions (I don’t even know what those are lol)

Don’t overwrite the root instance. Otherwise you’ll run into name conflicts.

The reason the other module returns a separate proxy is to prevent the root instance’s properties/children from conflicting with the attribute names


Eh, I don’t see a problem with it as long as you’re using it only for attributes and if you’re messing with attributes alot.

Additionally, adding something to be able to get the actual instance again could be cool, like :GetRaw() or something?

The issue with the code example is that they’re overwriting the workspace global, which unless you’re trying to proxy the variables for reverse engineering, really should not be done.

The example should be more like

local workspaceWithAttributes = MakeAttributesIndexable(workspace)

Oh yeah you shouldn’t be overwriting the global variable workspace, which can be a problem. I thought you meant something else. :sweat_smile:

im sad now i didn’t went to sleep and it’s 7am… send help

Just so that you can understand a bit, attributes are kind of like custom properties, like you see with “Position”, “Name”, etc. But attributes don’t let you just do: workspace.CustomAttribute for example. They decided not to for multiple reasons, but mainly because the method above was already used for a lot of other stuff too at the same time.

But anyways, instead, they decided to have a function which you change a attribute, and one to get an attribute, so instead you need to use :GetAttribute() and :SetAttribute(), doing this was better than using “.”, But it turns sometimes, inconvenient.

This instead let’s you use “workspace.CustomAttribute” for example, instead of using the methods I showed above.

If you don’t understand ANYTHING about scripting just know that using “.” means either you’re getting something inside of something else, so workspace.Part for example would get a part inside workspace, and that’s basically it, but using “.” is also for properties and stuff like that, so they decided to NOT use “.” for attributes.

Thanks for the tip. I’ve fixed that in the example. I’ve also cut down on a few redundant things in the module’s code.

Yeah, I know the basics like referencing and variables, and I know that attributes are like custom properties as it was explained, I just didn’t know what getter and setter were.

I won’t let you 1up me like this. :smile:


This is definitely what I prefer over get and set. Won’t use this but I like the idea a lot.

1 Like