Skip to main content

NetMessage

NetMessage is a data type used for transporting data between client and server when using NetworkEvent.

Constructors


Summary

Methods


Methods

NetMessage.New

NetMessage:NetMessage.New()

Creates a new NetMessage instance.

Methods


AddString

NetMessage:AddString(key: string, value: string)

Parameters:

ParameterTypeDefaultDescription
keystring-
valuestring-

Sets a key as a string.

Limitations

Adding a string longer than 65,535 characters will cause the message to be silently dropped during transmission, and the NetworkEvent will not be fired on the other side.

If you need to send a large string, consider sending it in smaller chunks.


GetString

NetMessage:GetString(key: string): string

Parameters:

ParameterTypeDefaultDescription
keystring-

Gets the value of a string key.


AddInt

NetMessage:AddInt(key: string, int: int)

Parameters:

ParameterTypeDefaultDescription
keystring-
intint-

Sets a key as an integer.


GetInt

NetMessage:GetInt(key: string): int

Parameters:

ParameterTypeDefaultDescription
keystring-

Gets the value of an integer key.


AddNumber

NetMessage:AddNumber(key: string, number: float)

Parameters:

ParameterTypeDefaultDescription
keystring-
numberfloat-

Sets a key as a float.


GetNumber

NetMessage:GetNumber(key: string): float

Parameters:

ParameterTypeDefaultDescription
keystring-

Gets the value of a float key.


AddBool

NetMessage:AddBool(key: string, bool: boolean)

Parameters:

ParameterTypeDefaultDescription
keystring-
boolboolean-

Sets a key as a boolean.


GetBool

NetMessage:GetBool(key: string): boolean

Parameters:

ParameterTypeDefaultDescription
keystring-

Gets the value of a boolean key.


AddVector2

NetMessage:AddVector2(key: string, vector2: Vector2)

Parameters:

ParameterTypeDefaultDescription
keystring-
vector2Vector2-

Sets a key as a Vector2.


GetVector2

NetMessage:GetVector2(key: string): Vector2

Parameters:

ParameterTypeDefaultDescription
keystring-

Gets the value of a Vector2 key.


AddVector3

NetMessage:AddVector3(key: string, vector3: Vector3)

Parameters:

ParameterTypeDefaultDescription
keystring-
vector3Vector3-

Sets a key as a Vector3.


GetVector3

NetMessage:GetVector3(key: string): Vector3

Parameters:

ParameterTypeDefaultDescription
keystring-

Gets the value of a Vector3 key.


AddColor

NetMessage:AddColor(key: string, color: Color)

Parameters:

ParameterTypeDefaultDescription
keystring-
colorColor-

Sets a key as a Color.


GetColor

NetMessage:GetColor(key: string): Color

Parameters:

ParameterTypeDefaultDescription
keystring-

Gets the value of a Color key.


AddInstance

NetMessage:AddInstance(key: string, instance: Instance)

Parameters:

ParameterTypeDefaultDescription
keystring-
instanceInstance-

Sets a key as an Instance.


GetInstance

NetMessage:GetInstance(key: string): Instance

Parameters:

ParameterTypeDefaultDescription
keystring-

Gets the value of an Instance key.