Help With Communicating 'buffers' from Server to Clients

What I want to achieve is an efficient way of communicating buffers created from clients that are sent to the server to be then sent back to various clients, and/or to know if my current method is okay.

I noticed that there is a size limit on communicating to the server from the client- of which I was able to meet when I tried to send many buffers at the same time to the server. What ended up happening was a client-sided disconnection, but I have since fixed and capped off the sending amount (I originally didn’t know that it could be met as easily with buffers) and now it only sends a few to the server (4 total with 512x512 pixels of image data). Is this too much to send from the client like every 5.5 seconds average, never below 5 (and up to 18 players at a time doing it)?

But anyways - since I think that the client to server is taken care of, now It’s the problem of displaying each image sent in to the clients.

I initially thought it was too much to send to each client (or too much requests to be sending from the server to each client ?) through a RemoteEvent, sending each client (16-18 players max) a total view of 8 buffer images EACH. So instead I opted to set attributes of each ImageLabel instead so that way the client can detect the change and then align themselves manually using attributes set by the server (set only once).

Well, this didn’t work out. This method was supposed to work by turning each of the server’s buffer data into strings, breaking down the string into sections with <= 100,000 characters (for any attribute limits) then setting an attribute from 1-to however many sections there would be divided to handle all the buffer’s string characters.

math.floor(#bufferdata/100000)+1 --usually around 10-13, then I use a for loop to string.sub out of the string version of the buffer from 1 to 10-13 and set an attribute for each...

When the client receives the changes, it confirms the total count of sections for each ImageLabel. It then combines each section of string using a for loop (like legos) and then taking that complete new string and using buffer.fromString() to turn it back into a buffer but I kept getting the error of “EditableImage:WritePixelsBuffer expects buffer length to equal size.X * size.Y * 4 bytes”.

When I check to make sure that all data is present when the client receives it, I make the server print how many sections of string there are and how many characters are in each section. When the client combines each string and totals the entire buffer length, it’s the same exact count printed out.

So instead (at-least right now) I just decided to have the client ask the server to return a Fire of each specific buffer needed (do not wanna use RemoteFunctions for this, so I use a RemoteEvent) and this happens for each of the 8 ImageLabels. This also happens very quickly from a loop at one time collecting for all 1-8 images, and there’s anywhere from 1-18 players in any given server.

Is this too much for the server to handle? Will it crash the server? Will it disconnect clients? Will it just error? I have so many questions. This is why the attribute way is perfect because the server doesn’t need to keep getting bothered and returning fire, and the clients can read and write at their own pace their own buffers from what the server has already provided ONCE.

On a side note, does breaking down the buffer into a string + into sections cause it to lose it’s data? Or become corrupted? What happens to make it not be able to be put back into a buffer having been broken down into sections of string?

Sorry if this is too long, but I really have no idea what to do.

Okay!!! It’s that time of day, where I investigate a little further and solve my own problem.

I changed 1 digit of number and fixed it all.

Sometimes using string.sub is tricky when you don’t pay attention all the time (like me ofcourse). When cutting the string into chunks in the server, I began the cuts by doing " string.sub(the stringed buffer, 1, 50,000) " (50,000 because it’s the limit I have for attributes that I don’t even want to come close to meeting, but I’m going to adjust slightly to 100,000 characters).
To keep cutting chunks until the end of the string, I ran the code " the stringed buffer = string.sub(the stringed buffer, 50,000, #the stringed buffer) " right after so that way I would be at the next section of string.

The problem is is that it was getting the last character of the previous string. So the string:
“abcdefghijklmnopqrstuvwxyz” is a total of 26 characters, it would be essentially the same as doing string.sub(alphabet,1,19) (being to ‘s’) and then string.sub(alphabet,19,#alphabet) being “stuvwxyz” instead of needing to be “tuvwxyz”. The fix would be to have the replacement of the original string to be more more than the cutting portion so that way it cuts properly (so string.sub(alphabet,20,#alphabet) ).

I ofcourse know better and dealt with string.sub for over 10 years now but dealing with such big numbers, and a process I didn’t honestly know if it would even work, I was negligent with typing the numbers properly.

Now I can use my beloved attribute setting way of communication :smiley: I posted this for anyone else potentially looking for a solution to the same/similar problem (1/100000 chance).