Table encoded to JSON, sent through messagingservice, is placed in a LUA table with an added unessential value

Hi, I am currently helping someone else out with their code, which involves a “multiplayer” system where one player servers are used and displays everyone else playing the game as a “brick”.

We are trying to send a table through the messagingservice using JSONEncode, and is successfully encoded. PublishAsync is called and the table successfully gets there. This table (not decoded) is then sent through to a function (which will happen on all servers). However, when printing the not even decoded table, the first line of the function, suddenly the encoded table that was all working fine became a LUA table with two “values”! “Data” and “Sent”. Sent has a bunch of numbers, for what reason I do not know.

As a result of this, when we attempt to decode the JSON to get back the LUA, the whole value returns nil, as its a lua table.

Why is this happening? I know a workaround but I still want to know why…

1 Like

It’s probably due to some bad logic inside the service. But it’s okay, it won’t cause any errors.
I’m guessing the service checks if the value you sent is a Table. If it is, it converts it to json. Then when another server checks the value, it checks if it is JSON, and assumes it should be decompiled if it is.

Yeah, my workaround is just decoding Table[“Data”] and all works fine.

But what makes the JSON re-convert to a lua adding a new “Sent” value to it?

Your workaround should be not to encode the table, you don’t need to.

You can’t send tables/dictonaries through publishasync, hence a workaround for that was to JSONEncode the table, which publishasync allowed. However during (transport) somehow the JSON was placed inside a LUA table with a new “Sent” value added, which was what I am enquiring about.


There is no error here.

Hm. Last time we tried it was giving an error about publishing dictionaries. I don’t know what happened and why.

1 Like