Attributes or values are faster for frequent replication?

Hello
I need to change the value of an attribute related to the player several times per second.
This value will be changed on the server and read by the client.
From performance point of view, is it better to create an attribute under the player or IntValue under the player?

Thanks

2 Likes

Changing the Value of an IntValue will always beat setting an attribute in terms of network traffic. Even with an attribute name that is only one character long, it took about 50% more data to update that attribute than updating the IntValue in a test I did with 1000 objects being updated every heartbeat, and attribute performance only got worse as attribute name length increased.

EDIT: I should qualify this a bit more. Most of the advantage is specific to the object being an IntValue since those objects use 32-bit integers to store their values rather than 64-bit doubles used everywhere else in Lua. When using other ValueObjects, the difference isn’t as substantial.

4 Likes

Thanks for the clarification
I was wondering - if I change an attribute on the player, will this replicate the whole player to the client - with all other attributes?
and if I change IntValue under the player, may be it will replicate only the IntValue?

1 Like

Either change should only require replicating data about the affected Instance, but making property changes can be optimized in ROBLOX’s backend because the behavior is well-defined. When changing an attribute, it still needs to send information about the affected object and the new value, but it also has to send information about the attribute being changed, and that takes more data than however property changes are communicated.

2 Likes

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