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…
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.
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.