Skip to content

API

Bolt

Functions

.ReliableEvent

Bolt.ReliableEvent<T...>(eventName: string, serializer: ((writer: BufferWriter, T...) -> ())?, deserializer: ((reader: BufferReader) -> T...)?): ReliableEvent<T...>

Creates a ReliableEvent that is used for communication between client <-> server with a guaranteed delivery on both sides.

.RemoteProperty

Bolt.RemoteProperty<T>(propertyName: string, defaultValue: T, serializer: ((writer: BufferWriter, T) -> ())?, deserializer: ((reader: BufferReader) -> T)?): RemoteProperty<T>

Creates a RemoteProperty that automatically synchronizes its value to Players.

.RemoteFunction

Bolt.RemoteFunction<T..., R...>(functionName: string): RemoteFunction<T..., R...>

Creates a RemoteFunction that allows for clients to execute server functions just like they would do on the client side. The code invoking the function yields until it receives a response from the server.

Warning

Bolt doesn't allow for server to client remote function calls as it's a security risk that's not worth the convinience.

ReliableEvent

Properties

OnClientEvent

ReliableEvent.OnClientEvent: RestrictedConnector<T...>

Fires on client side when the server sends an event.


OnServerEvent

ReliableEvent.OnServerEvent: RestrictedConnector<Player, T...>

Fires on server side when the client sends an event.

Functions

:FireServer

ReliableEvent:FireServer(...: T...): ()

Fires the OnServerEvent event on the server from one client. Connected events receive the Player argument of the firing client. Since this method is used to communicate from a client to the server, it only works when used in a client script.

Warning

This property can be only called from client scripts.


:FireClient

ReliableEvent:FireClient(player: Player, ...: T...): ()

Fires the OnClientEvent event for the specific client in the required Player argument. Since this method is used to communicate from the server to a client, it only works when used in a server script.

Warning

This property can be only called from server scripts.


:FireAllClients

ReliableEvent:FireAllClients(...: T...): ()

Fires the OnClientEvent event for each connected client. Unlike FireClient, this event does not take a target Player as the first argument, since it fires to all connected players. Since this method is used to communicate from the server to clients, it only works when used in a server script.

Warning

This property can be only called from server scripts.

RemoteProperty

Functions

:Observe

RemoteProperty:Observe(callback: (value: T) -> ()): (() -> ())

Registers a callback function that gets called whenever the property value changes.

Registering a callback also means that the first callback it will receive will be the current value of that RemoteProperty.

Returns a function that when called disconnects the callback from the RemoteProperty and any further value updates won't be received by this callback function.

Warning

This property can be only called from client scripts.


:Get

RemoteProperty:Get(): T

Returns the current value of the property.


:GetFor

RemoteProperty:GetFor(player: Player): T

Returns the current value of the property for a given player.


:Set

RemoteProperty:Set(newValue: T): ()

Sets the value of the remote property to the newly passed one, if the new value is the same as the old value, the value update will be skipped.

When Set is called all of the values set for players using SetFor get cleared and are set to the newly passed value.

Warning

This function can be only called from server scripts.


:SetFor

RemoteProperty:SetFor(player: Player, newValue: T): ()

Sets the value of the remote property for that given player, if the new value is the same as the old value, the value update will be skipped.

Only this specific player will receive the value update, an "overwrite" gets created for this specific player and any further SetFor calls will compare the new value with this one.

Warning

This function can be only called from server scripts.


:ClearFor

RemoteProperty:ClearFor(player: Player): ()

Clears the overwriten value that was set by SetFor, if the master value that was set for this remote property is different from the value that was overwritten for the specific player passed in the parameter, they will get a value update.

Warning

This function can be only called from server scripts.

RemoteFunction

Properties

OnServerInvoke

RemoteFunction.OnServerInvoke: (player: Player, ...: T...): R...

This callback is called when the RemoteFunction is invoked with InvokeServer. When the bound function returns, the returned values are sent back to the calling client.

Example Usage
local remoteFunction = Bolt.RemoteFunction("Foo") :: Bolt.RemoteFunction<(), (string)>

remoteFunction.OnServerInvoke = function(player)
    return player.DisplayName
end
local remoteFunction = Bolt.RemoteFunction("Foo") :: Bolt.RemoteFunction<(), (string)>

print(remoteFunction:InvokeServer()) --> username

Warning

This property can only be set from server scripts.

Functions

:InvokeServer

RemoteFunction:InvokeServer(...: T...): R...

Danger

This function yields.

Invokes the RemoteFunction which in turn calls the OnServerInvoke callback. Since this method is used to communicate from a client to the server, it will only work when used in a client script.

Any type of Roblox object such as an Enum, Instance, or others can be passed as a parameter to InvokeServer(), as well as Luau types such as numbers, strings, and booleans.

Warning

This property can be only called from client scripts.

BufferReader

Functions

.fromBuffer

BufferReader.fromBuffer(buffer: buffer): BufferReader

.fromBuffer

BufferReader.fromString(string: string): BufferReader

:ReadB8

BufferReader:ReadB8(): { boolean }

:ReadI8

BufferReader:ReadI8(): number

:ReadI16

BufferReader:ReadI16(): number

:ReadI24

BufferReader:ReadI24(): number

:ReadI32

BufferReader:ReadI32(): number

:ReadU8

BufferReader:ReadU8(): number

:ReadU16

BufferReader:ReadU16(): number

:ReadU24

BufferReader:ReadU24(): number

:ReadU32

BufferReader:ReadU32(): number

:ReadU40

BufferReader:ReadU40(): number

:ReadU56

BufferReader:ReadU56(): number

:ReadF32

BufferReader:ReadF32(): number

:ReadF64

BufferReader:ReadF64(): number

:ReadInstance

BufferReader:ReadInstance(): Instance

:ReadString

BufferReader:ReadString(count: number?): string

:ReadVector2

BufferReader:ReadVector2(): Vector2

:ReadVector3

BufferReader:ReadVector3(): Vector3

:ReadCFrame

BufferReader:ReadCFrame(): CFrame

:ReadColor3

BufferReader:ReadColor3(): Color3

BufferWriter

Functions

.new

BufferWriter.new(size: number): BufferWriter

.fromBuffer

BufferWriter.fromBuffer(source: buffer): BufferWriter

:WriteB8

BufferWriter:WriteB8(...boolean): ()

:WriteI8

BufferWriter:WriteI8(value: number): ()

:WriteI16

BufferWriter:WriteI16(value: number): ()

:WriteI24

BufferWriter:WriteI24(value: number): ()

:WriteI32

BufferWriter:WriteI32(value: number): ()

:WriteU8

BufferWriter:WriteU8(value: number): ()

:WriteU16

BufferWriter:WriteU16(value: number): ()

:WriteU24

BufferWriter:WriteU24(value: number): ()

:WriteU32

BufferWriter:WriteU32(value: number): ()

:WriteU40

BufferWriter:WriteU40(value: number): ()

:WriteU56

BufferWriter:WriteU56(value: number): ()

:WriteF32

BufferWriter:WriteF32(value: number): ()

:WriteF64

BufferWriter:WriteF64(value: number): ()

:WriteInstance

BufferWriter:WriteInstance(instance: Instance): ()

:WriteString

BufferWriter:WriteString(string: string, count: number?): ()

:WriteVector2

BufferWriter:WriteVector2(value: Vector2): ()

:WriteVector3

BufferWriter:WriteVector3(value: Vector3): ()

:WriteCFrame

BufferWriter:WriteCFrame(value: CFrame): ()

:WriteColor3

BufferWriter:WriteColor3(value: Color3): ()

:Fit

BufferWriter:Fit(): ()

Shrinks the internal buffer size to the current internal cursor offset.