I have recently learned about attributes (ie. the custom fields at the bottom of every object’s properties). After using them for a while, I’ve found that I can achieve everything I can do with tags much more easily with attributes. For example, here’s a shortened version of a script that I wrote a while back that depends on tags:
if part:HasTag("x") then
vector = Vector3.xAxis
elseif part:HasTag("y") then
vector = Vector3.yAxis
elseif part:HasTag("z") then
vector = Vector3.zAxis
end
It’s somewhat boilerplate-y and I could’ve avoided it all by simply putting the tag into an attribute and using vector = Vector3[part:GetAttribute("Tag")] .. "Axis"]
. I can imagine that for more complex scenarios (eg. where there are more tags to check), using attributes would cut it down even more.
So, if using attributes cuts down on this much boilerplate, why do tags exist? Are there hidden advantages to using tags (eg. performance) that I can’t easily see? Or are they just really convenient in enough niche scenarios that I shouldn’t forget about them?