As a Roblox developer, it is currently too hard to apply complex state to an Instance using Attributes.
Attributes are a great step in the right direction for being able to associate data with instances, however I would like to see support for tables released as well.
My use case is that, I frequently have complex state for my players that I need synchronized between the server and client. For example, say I have the following state table:
Currently, I have to send data like this through remotes to sync it up, and it gets complicated trying to juggle that. Since I typically have nested data, I can’t easily use Attributes to have this data applied via Attributes either. It would be convenient for me to be able to attach that type of state table to its respective player, so that it easily replicates to each client when I make changes, and so I don’t have to think about juggling the usual networking required for this.
If Roblox is able to address this issue, it would improve my development experience because I would no longer have to deal with complicated networking to sync up a player’s state with the server and other other clients.
Attributes are a perfect avenue for automatically replicating data, and I know tables have been in the pipeline for getting support, so I wanted to throw in my use case to hopefully get this feature prioritized.
Hi @vocksel, I would like to ask what are the data types that you need for Tables to support when added as an Attribute?
I might decide to add this functionality to AttributeService as a temporary solution until Roblox officially supports Tables.
I have attempt this before and it wasn’t easy at all and you are better off using Remotes anyways due to Dependency reasons. (I can really understand why Instances and Tables are not supported upon Attributes official released.
In short you have to serialize and support a lot of data types which makes it very complex)
I do support this feature request and definitely would like to see Tables, Instances and CFrames support soon, however if you require complex Tables to replicate then using Remotes is your best option, especially when data changes very frequently.
I think where something like this gets hairy is when you get to the replication side of things. One would think that a table is a really obvious feature that Roblox could easily add in with everything else, but when it comes to replication, you can see why something like this would be tough to do.
There was actually a post about a TableValue Instance but as you can see in the comments, replicating the table would require putting the table in JSON format (which gets rid of certain metadata like colors, functions, etc) or creating a custom replication system, which would quickly turn into a huge job for roblox and can already be implemented by devs in Lua.
So it’s probably not impossible, but just a lot harder than it seems, and that’s why Roblox hasn’t prioritized something like this (although it would be really nice to use instead of ModuleScripts that can cause memory leaks if used improperly).
Your right there could be some issues with replication. My solution is make it non replicatable. Many values and properties in Roblox are not replicated to clients. I think most use cases for attributes with table values are to store inventory data or similar stuff which usually is not necessary to be automatically replicated.
Would love to have simple arrays for attributes, an example would be an ItemSpawner that has an array of strings of items it can spawn, rather than just one single item.