Placement System Predicament

Here’s my own two cents about compression (hopefully capturing @McGamerNick’s original intent).

I’ll assume that you’ll probably want to have different tweens and effects for each object. This is the most the straightforward way to do it.

local PlaceEvent: RemoteEvent

PlaceEvent:FireAllClients(
	model:: string, 
	cframe:: CFrame, 
	particleEmitter:: Instance, 
	TweenInfo.new(0.3, Enum.EasingStyle.Sine):: TweenInfo
)

There are so many things to consider, but generally speaking:

  • Arrays > Dictionaries
    • Arrays use numerical keys (typically 1 byte) while dictionaries typically use non-numerical keys such as strings which cost unnecessary bytes.
  • Vector3int16.new() > Vector3.new() > CFrame.new()
    • CFrames have a positional and rotational component. Depending on your usecase, you can further compress these components into Vector3s, Vector2s, and sometimes even numbers.
  • Vector2int16.new() > Vector2.new()
  • Numbers > Strings
    • In application, numbers are normally 8 bytes (static; doesn’t change with amount of digits), but you can compress these numbers (e.g. only 1 byte which can represent an unsigned integer range of [0, 255]) and send them over instead of strings which increase by 1 byte per character.
  • Numbers can also be compressed further with buffer.new()
  • TweenInfo seems similar to a dictionary

For specific byte sizes of each datatype, read this post by @PysephDEV. Although there are a very few details that are outdated, so you can also read this (from the same person). I recommend these two if you want to comprehend the comparisons I made above, though you may need to do further research for the other stuff (such as buffers).

Now to visualize your network bandwidth, I recommend PacketProfiler (by the same person)! It’s basically a prediction of how much bytes are being sent over with each RemoteEvent call. Do keep in mind that certain datatypes (such as TweenInfo) are unfortunately not visualized.

If you want to see how you could apply some of the considerations above, you can read this section on a post I made specifically about compressing dictionaries, CFrames, and numbers.

2 Likes