Skip to content

Server

A Server-sided Connection

.new

Create new FastNet2 event

lua
(
	Identifier: string,
	reliable: boolean
)
(
	Identifier: string,
	reliable: boolean
)
lua
local Remote = FastNet2.new("Remote", false) -- is unreliable event
local Remote2 = FastNet2.new("Remote", true) -- is reliable event
local Remote3 = FastNet2.new("Remote") -- is also reliable event
local Remote = FastNet2.new("Remote", false) -- is unreliable event
local Remote2 = FastNet2.new("Remote", true) -- is reliable event
local Remote3 = FastNet2.new("Remote") -- is also reliable event

Identifier will converte/encode into hash identifier

:Connect or :Listen

Listen an event from the client to receive, :Connect and :Listen is the same function.

lua
(
	player: Player,
	callback: (...any) -> ()
)
(
	player: Player,
	callback: (...any) -> ()
)
lua
Remote:Connect(function(player, ...)
	print(...)
end)
Remote:Connect(function(player, ...)
	print(...)
end)
lua
-- to know if the event is connected or not by doing `.Connected`
print(Remote.Connected)
-- to know if the event is connected or not by doing `.Connected`
print(Remote.Connected)

Each event only allowed have one callback.

:Once

This function is same as :Connect but it disconnect the event once it fired.

lua
(
	player: Player,
	callback: (...any) -> ()
)
(
	player: Player,
	callback: (...any) -> ()
)
lua
Remote:Once(function(player, ...)
	print(...)
end)
Remote:Once(function(player, ...)
	print(...)
end)

:Disconnect

Disconnect the event

lua
Remote:Disconnect()
Remote:Disconnect()

:Fire

Fire the event to the spesific client with data.

lua
(
    player: Player,
	...: any
)
(
    player: Player,
	...: any
)
lua
Remote:Fire(player, "Hello World!")
Remote:Fire(player, "Hello World!")

:Fires Server Only

Fire the event to all clients with data.

lua
(
	...: any
)
(
	...: any
)
lua
Remote:Fires("Hello World!")
Remote:Fires("Hello World!")

:Invoke

Semiliar with :InvokeClient, its for doing Invoke to spesific Client.

lua
(
	timeout: number,
    player: Player,
	...: any
) -> (...any)
(
	timeout: number,
    player: Player,
	...: any
) -> (...any)
lua
local Request = Remote:Invoke(2, player, "Hello World!")
local Request = Remote:Invoke(2, player, "Hello World!")

WARNING

This function is yielded, and the minimum for timeout is 2 (seconds)

:Wait

Wait the event that triggered/pinged

lua
Remote:Wait()
Remote:Wait()

WARNING

This function is yielded

:Destroy

Disconnect the event and Remove the event from FastNet2

lua
Remote:Destroy()
Remote:Destroy()