NetMessage
NetMessage is a data type used for transporting data between client and server when using NetworkEvent.
Constructors
Summary
Methods
NetMessage.New:voidAddString:voidGetString:stringAddInt:voidGetInt:intAddNumber:voidGetNumber:floatAddBool:voidGetBool:booleanAddVector2:voidGetVector2:Vector2AddVector3:voidGetVector3:Vector3AddColor:voidGetColor:ColorAddInstance:voidGetInstance:Instance
Methods
NetMessage.New
NetMessage:NetMessage.New()
Creates a new NetMessage instance.
Methods
AddString
NetMessage:AddString(key: string, value: string)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - | |
value | string | - |
Sets a key as a string.
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:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - |
Gets the value of a string key.
AddInt
NetMessage:AddInt(key: string, int: int)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - | |
int | int | - |
Sets a key as an integer.
GetInt
NetMessage:GetInt(key: string): int
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - |
Gets the value of an integer key.
AddNumber
NetMessage:AddNumber(key: string, number: float)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - | |
number | float | - |
Sets a key as a float.
GetNumber
NetMessage:GetNumber(key: string): float
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - |
Gets the value of a float key.
AddBool
NetMessage:AddBool(key: string, bool: boolean)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - | |
bool | boolean | - |
Sets a key as a boolean.
GetBool
NetMessage:GetBool(key: string): boolean
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - |
Gets the value of a boolean key.
AddVector2
NetMessage:AddVector2(key: string, vector2: Vector2)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - | |
vector2 | Vector2 | - |
Sets a key as a Vector2.
GetVector2
NetMessage:GetVector2(key: string): Vector2
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - |
Gets the value of a Vector2 key.
AddVector3
NetMessage:AddVector3(key: string, vector3: Vector3)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - | |
vector3 | Vector3 | - |
Sets a key as a Vector3.
GetVector3
NetMessage:GetVector3(key: string): Vector3
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - |
Gets the value of a Vector3 key.
AddColor
NetMessage:AddColor(key: string, color: Color)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - | |
color | Color | - |
Sets a key as a Color.
GetColor
NetMessage:GetColor(key: string): Color
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - |
Gets the value of a Color key.
AddInstance
NetMessage:AddInstance(key: string, instance: Instance)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - | |
instance | Instance | - |
Sets a key as an Instance.
GetInstance
NetMessage:GetInstance(key: string): Instance
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
key | string | - |
Gets the value of an Instance key.