This is highly irritating, and for my game I have had to switch the way my tables are organized before every event I fire, perform a deep table copy, and change all the numbers with tostring(), which is a huge waste of time, and processing power, and now I just ran into an instance where every single one of my events will need to be called this way, and I’m sick and tired of having to do such a foolish thing, lua is supposed to naturally support strings and numbers hand in hand, please just add it to where you can transfer table keys as numbers as well T.T I will have to put in at least two hours of work changing all my scripts over now, just for this stupid error, two hours I don’t have, already working over time on my game that my users are getting impatient about.
Would you rather be wasting processing time or network time?
I’d rather be wasting processing time, so I’m going to say no.
Considering it can’t be that hard to just send the number as a string, and convert it back, would it really waste any? or howabout the fact that numbers cost a ton less than text in the amount of bytes they take up, having one extra bit assigned to number/text will likely save networking, since I’d just call tostring() on my numbers anyway, and the amount of processing power to change over the tables is more than you are thinking, this happens every 0.1 seconds in my game, and the table can get to where it has 500+ number keys later on in the round.
um are you asking about how to send Dictionary Tables over Events without losing some values? If so my work around was to change the Table into a string via JSON and then transfer it over, and then decode it back into a table
-- Server Code
gr.OnServerEvent:connect(function(player,ppsd)
local FormatedTable = game:GetService("HttpService"):JSONDecode(ppsd)
end)
-- Client Code
local PSD = {} -- some large table with key and number indexes.
local memo = game:GetService("HttpService"):JSONEncode(PSD)
gr:FireServer(memo)
Also why are you sending a table of 500+ values every 0.1 of a second? your gonna kill your networking speed.
If you really really have to send mixed data, then I would recommend transforming your table like so:
Table[Key → Value] → Array[ {K = Key, V = Value} ]
However, you should really avoid using mixed data in your code. Pretty much everything should be either an array, a map with string keys, or a non-flat data structure that you can’t serialize directly anyways.
It doesn’t kill my networking speed because I handle all the networking for my game, there’s not a single object that roblox networks, not even the character. chat, I guess you could kinda count, but that’s hardly relevant, as I plan on replacing that too.
I don’t have mixed data tables, I have tables that have tables inside of them, and some are stored with strings (the inner tables, because they are almost-metatable tables), and the outer table that stores them all uses numbers as indices, because the objects are stored by ID, and not by name.
Not sure what you’re talking about losing some values, it’s never happened to me before, my problem is that roblox is giving me this error ‘keys must be strings’ and it’s costing my game a ton of CPU time to code the numbers into strings, and then back