Attributes vs CollectionService

I’m using Attributes to set whether a character is using a move or disabled or equipped their weapon

Should I use collection service instead to add tags? Is there any differences or reasons to use one over the other?

1 Like

Tags are typically used to track when objects are added or removed from said tag, and perform an action with them when it happens.

Attributes are typically used to store data about an entity or whatever else, as well as marking instances.

To me it sounds like attributes would be best for your use case, but depending on what exactly you’re planning on doing with this information, it may be better to simply store these values in a script with the code that’s using them.

4 Likes

Attributes are going to be faster, but more limited.
CollectionService is going to be slower, but much more flexible.
If your only use for the Tags is to read and write from them, I would definitely go with Attributes. In fact, I would use Attributes for almost anything. The only instance where I would recommend using CollectionService is if you need multiple tags on a single object. For example, if you have an object that is both a Hat and a Tool, you could put the object in both the Hat and Tool folders.

1 Like

I thought of using a modulescript to store values, but I didn’t want to require it everywhere.

I don’t know exactly how your game is structured, nor how you’d like it to be structured so I cannot give much in the way of advice.

Though for me, a general rule of thumb is that if you have an entire ModuleScript that exists only to hold values (unless these are utility values such as the magic number needed to convert from studs to miles etc.) you’re likely doing something wrong.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.