Roblox uses a table serialization algorithm that doesn’t support any keys in tables other than string or array keys. Obviously this leaves out many table structures which are incredibly common and useful, such as:
- Key = player’s user ID, value = player’s data table.
- Key = player’s house, value = player who owns the house.
- Key = boolean, value = data to use based on the truthiness of a statement.
This algorithm shows up in (at least) the following situations:
- RemoteEvent argument passing.
- BindableEvent argument passing.
- DataStore saving.
- Inspecting tables in the Lua debugger with breakpoints.
Please add full support for all valid table key types to the table serialization algorithm.
This will only become more important once Typed Luau is out of beta, because developers will want table keys to be of their custom data type (technically, a table).
This also adds a point of confusion for new developers when it shouldn’t. Why should someone new to Lua have to learn about the intricacies of when an integer key goes into the array, and when it goes into the hashmap?
Many of my more complicated bugs involve “complex” structures in tables. The debugger just tells me what memory address a table is at, which is not usually useful. With a better serialization algorithm, Roblox can add full support for table inspection in the debugger, including with tables as keys inside tables.
For DataStore saving, userdata could still be unable to be saved while still allowing other valid table structures.
Related topics about individual cases of this issue: