Skip to content

Buffer


Overview

Buffer is a module for writing compressed data to improve performance when needed. The module also includes methods for serializing and deserializing data, as well as some utilities like Buffer.Enum, Buffer.Constants, and Buffer.Utils.


Version

Buffer V3.0


Getting Started

Note

  • This module should be used with caution as it can be easy to deserialize a buffer without a predefined schema
  • The buffer inside the component can be encrypted if you really want to ensure its security

This module can be somewhat complicated to use if you are not familiar with buffers or directly with bytes/bits.


Data-type

Buffer contains over 30 data types. Find each type here:


Signed-Int

Type Min-Max
I1 -1 to 1
I8 -128 to 127
I16 -32,768 to 32,767
I24 -8,388,608 to 8,388,607
I32 -2,147,483,648 to 2,147,483,647
I40 -549,755,813,888 to 549,755,813,887
I48 -140,737,488,355,328 to 140,737,488,355,327
I54 -9,007,199,254,740,992 to 9,007,199,254,740,991

Unsigned-Int

Type Min-Max
U1 0 to 1
U8 0 to 255
U16 0 to 65,535
U24 0 to 16,777,215
U32 0 to 4,294,967,295
U40 0 to 1,099,511,627,775
U48 0 to 281,474,976,710,655
U54 0 to 18,014,398,509,481,980

Float

Type Description
F16 Half-precision float
F32 Single-precision float
F64 Double-precision float

Roblox Types

Type Description
Bool1 1-bit
Bool8 8-bit (each bool cost 1 bit)
Strings With various length limits: 8, 16, 32, 64 chars or unlimited
Color3 RGB
Vector2 X,Y (16 bytes)
Vector3 X,Y,Z (24 bytes)
Vector2Int16 X,Y (4 bytes)
Vector3Int16 X,Y,Z (6 bytes)
CFrame 96 bytes
LossyCFrame Compressed version of CFrame (48 bytes)
UDim Scale,Offset (8 bytes)
UDim2 X.Scale, Y.Scale, X.Offset, Y.Offset (16 bytes)
Rect 32 bytes
Region3 120 bytes
Region3Int16 16 bytes
Instance Stored in a separate instance buffer
vector luau vector library (24 byte)
Enum Roblox EnumItem (4 byte)
NumberRange 8
FloatCurveKey 16 or 24 (if you use KeyInterpolationMode.Cubic)
RotationCurveKey 104 or 112 (if you use KeyInterpoliationMode.Cubic)
ColorSequence 1 + 16 * number of ColorSequenceKeypoint
NumberSequence 1 + 12 * number of NumberSequenceKeypoint

Writing

To write each data type, methods starting with :Write are used:

Write Methods List :


Reading

To read written values, methods like :Read[TypeName] will be used.

Note

The first argument for each Read is the offset, which is 0-based. Expect for ReadInstance which need to start at 1.

Read Methods List :