Attributes vs Value, which is better?

valuesㅤㅤVSㅤㅤ attributes

Values vs Attributes


Scores:
1 for significant functions
0.5 for cosmetic functions


Function Attributes Values Explanation
Waste of memory
1 :white_check_mark:
0 :x:
Attributes take up less memory on your device, which is good. +1
Data update rate
2 :white_check_mark:
0 :x:
Attributes are updated and created 18 times faster than values. +1
Speed of removal
3 :white_check_mark:
0 :x:
Attributes are deleted ~240 times faster than values. +1
Data update method
3 :x:
0.5 :white_check_mark:
Cosmetically, updating values is easier than updating attributes. +0.5
Unity
3 :x:
1 :white_check_mark:
If your attribute does not depend on a specific element, then it may not be easy to constantly request it from different sources. +0.5
Getting data
3.5 :white_check_mark:
1 :x:
It is easier to get data from dependent attributes than from values. +0.5
Number of options
4 :white_check_mark:
1 :x:
Attributes support more functionality and technical features. +0.5
Errors
4.5 :white_check_mark:
1 :x:
Attributes return nil if the value does not exist. +0.5
Interaction in the studio
4.5 :x:
1.5 :white_check_mark:
It is easier and faster to interact with values in the studio. +0.5
Future support
5 :white_check_mark:
1.5 :x:
Attributes are a newer method and will receive longer-lasting future support as well as new features. +0.5
Replication
6 :white_check_mark:
1.5 :x:
The attributes is replicated immediately, along with the instance. +1
Sorting
6 :x:
2 :white_check_mark:
If you have a lot of values, then it’s easier to sort them, unlike attributes. +0.5

Result:

  • Attributes will be better than Values, as they are new methods and outperform them in points (6 vs 2).

Additional Information:

  • Q: If attributes are better than Values, does this mean that using Values is bad?
  • A: No, values are also a good tool. You won’t feel much difference. You should think about attributes if you have a large project.

  • Q: What is cosmetic functions?
  • A: Cosmetic functions are functions that facilitate the interaction process, but do not improve it.

Information: New Studio Beta: Attributes!

13 Likes

I thought it meant porting it to Unity. It’s the 17236067693276th time my thoughts are wrong.


I would use both Attributes and Values. but This belongs in #resources:community-tutorials as you aren’t making something new but rather comparing Attributes and Values

3 Likes

I would not say that your thoughts are wrong, rather unusual, which is also good. Also thanks for the correction, I didn’t know which topic was more suitable for this post, so I chose the Resources.

1 Like

When I first saw “Unity” I thought it meant the game engine

image

4 Likes

yes i get it! ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ

This is a good report. I use attributes for things like “Custom Character Properties”. Values should only be used for constant things like leader stats and player data. Attributes would be recommended for nonconstant things like characters and entities.

Attribute Example:
Function that creates a new projectile. Store damage into the projectile with an attribute. When the projectile is registered deal the damage dependent on the Damage attribute.

Value Example:
Function that updates Player kills in leaderstats after a kill.

It is honestly best practice to only use Values for leaderstats. Use CollectionService instead of ObjectValues.

4 Likes

Hold on, 0? Didn’t they return nil?

3 Likes

How can CollectionService be used as an alternative to ObjectValues? CollectionService can be used to group instances with the same purpose. An ObjectValue, on the other hand, can be used to store a reference to an instance that is somehow related to a spesific other instance.

3 Likes

Yes, you are right, in this post for some reason written 0 and I decided to write the same, but it seems that this may confuse some people.

1 Like

People sometimes use ObjectValues to store values that parents can change a lot. I’ve seen it in other peoples code many times.

1 Like