So I've recently returned to Roblox Lua and have been working on a mini project involving some client-server communication. So far, the client will request some data from the server using a RemoteFunction and the server will respond with the corresponding table, simple enough right? The problem is during upon receiving the data, it appears to delete and alter any attribute keys with a value less than 1. Example:
Server (what is sent):
{ [-1] = "Test1", [0] = "Test2", [1] = "Test3", [2] = { [0] = "Test4" } }
Client (what is received):
{ [1] = "Test3", [2] = { ["0"] = "Test4" } }
At first I assumed it was just a Lua thing caused by 1-based indexing, however before transmission the data is perfectly fine and readable. Anyone have any idea as to why this might be?
Edit: Another thing to note - removing the [1] attribute prevents the sub-1 elements from being removed, and turns all the keys into strings. Guess that kind of confirms the indexing theory, although it doesn't explain why the remotes are handling it so strangely.
If I had to make a wild guess, it's probably some limitation with RemoteEvents, for example, you cannot have mixed strings and number as keys in a table. Your example should be quite easy to solve by simply changing all keys to strings.