RamJoT makes a good point, only the data variable is the only table you have. The reason this is an issue is because you cannot transfer tables over the server with “mixed”/“non-array” keys. So if you use different keys like data[“ID”], data, and data[player], the server won’t pass the table (hence the error). That is why RamJoT would like to see the contents of your data table.
Why don’t you just set those to strings then? data[tostring(player.UserId] will abide by what the error is spitting out, and you still keep the same key, just in a different format.
The reason your method doesn’t work is you are not providing an array; you listed keys in an unorganized format and not in sequence. That’s why player ID’s are not good keys to use in numerical form. By using a string, you are defining a set of keys that don’t have a sequence and are of the same data type.
Let me reiterate that an array has a defined order - a sequence - of keys. And they always start at 1, so your data table will look like data, data, … , data[player1ID], … , data[player2ID], …
In essence, you are leaving holes in the sequence that you have not defined. You cannot do this when you send tables across the server as arrays. That is what the error is trying to tell you. That is why it has to be a string (or some other data type, just not an integer) since an integer key describes arrays. They are called dictionaries but most people just call everything tables here.
If you are still confused, I suggest spending some time here. The wiki goes over the difference between the two types of tables in more depth.
I’m guessing (and I don’t really have a source for this, but it’s based on my common sense so maybe someone can verify) that Roblox doesn’t allow disordered arrays to be sent across the server because of the extra data within the holes that are undefined. Something about hundreds of thousands of holes feels like a waste of memory to me in an ordered list.
I’m not sure, but I think something like that is kind of pointless. Why not just put everything in the table? Then you only need one parameter.
I haven’t run into this before because I usually put everything in a table if the data I want to send is a large amount. Perhaps someone with more knowledge regarding this can help explain why your second block doesn’t work.