I recall that saving tables with non-string keys would throw an error upon saving. However, upon testing right now I can run this script in Studio just fine.
The only situation in which you would use string keys is having whitespace in the key, which as a programmer, you should get used to not doing regardless.
Your example is not a mixed table. Each (sub)table in your example has either all string or array indices. This format has always worked fine.
This is an example of a mixed table that most likely would not save to datastores properly / cause an error to be thrown:
local data = {
"hello", -- index 1
a = 1, -- string index
b = 2 -- string index
}
This would also error, because you can’t have numerical indices that don’t form an array (1,2,3,… without holes):
local data = {
[1] = "hello",
[2] = "this",
[4] = "won't",
[7] = "work"
}
If you add a (sub)table with numerical indices, it needs to be an array.
@Kiansjet this is not just functionally identical, it is completely identical to each other. Both of your examples have the same string key in the table. Adding the [“…”] or leaving it out is just syntactic sugar.