ObjectValues vs Attributes

Are there pros and cons to using Object Values (e.g. IntValues, BoolValues) as opposed to adding Attributes to my instances?


Have you researched the topic from the announcement post?

You can view all Attributes on an instance at once, unlike a value object which only supports a single value and therefore you must look at each individually.

In terms of performance, the difference is mostly negligble with a few exceptions:

Attributes take up less memory on your device
Attributes are ~18x faster to create dynamically
Attributes are ~240x faster to delete

For the object values pros there’s still things only they can do like store instance object values which attributes cannot.


Attributes are probably the future, since they are newer. ObjectValues are still used for making ‘leaderstats’.


Back then, BaseValues (The proper name for them) were the common way of adding values. You could add some to a Player, and they were just an Instance for values. For example, lets say a Player was in Jail. You would set Player.InJail.Value to true. But as @dthecoolest said, they are faster, and Roblox’s recommended way of values. Now you could make custom properties!

BaseValue vs Attributes

Obby Level


Player.Level.Value = Player.Level.Value += 1
-- Or
Player.Level.Value += 1


Player:SetAttribute("Level", Player.Level.Value:GetAttribute("Level") + 1)
-- You could also make a function to increment attributes easily.

Getting the level:

-- Values:
if Player.Level.Value == 5 then
-- Do something
-- do something else, probably kill the player
-- Attributes
if Player:GetAttribute("Level") == 5 then
-- Do something
-- Do something else, prob kill
1 Like

If you’re looking at building reliable software, probably stay away from base values on the client and only use them for information for the server.

The problem is because of replication - they do not replicate with their parent, so you can easily get situations where on a client the parent has replicated but all of its base values have not - and you have no way of knowing if the replication is complete or not.

Attributes replication is better - they replicate instantly making them suitable for work on both client and server, but have some flaws too.

Base values have one neat feature - which is the Object Value type. You can point to another object in your hierarchy, which is something attributes cannot do.

You can’t search for attributes, but you can search for base values with the hierarchy inspector.

You can cut and paste base values, you can’t cut and paste attributes.

Attributes have a number range type! This is good for making acceleration curves and other effects - very common tool in unity. Unfortunately you have to write your own code to sample from it, but it’s a good start.


I think attributes are very good for unchangable stats because it takes to long to change:
instance:SetAttribute('Damage',instance:GetAttribute('Damage') + (something))
but it easier to get a lot of data:
or get a single data

with values:

1 Like