Skip to content

Basic Usage

For first, visit the Installation page to install the Wisp library in your game/project

Before Start

For first, require the imported library:

lua
local Wisp = require(game.ReplicatedStorage.Wisp) -- or everywhere

Due to problems with LSP Roblox (Luau), you will have to get the execution side (Client, Server) yourself. Here's how it works:

lua
local Wisp = require(game.ReplicatedStorage.Wisp).Client
-- Now you can freely use Wisp
lua
local Wisp = require(game.ReplicatedStorage.Wisp).Server
-- Now you can freely use Wisp

AwaitReady

If there are a lot of RemoteEvents/RemoteFunctions or if the hardware is poor, the client may not be able to initialize correctly. Therefore, it is recommended to use the Wisp.AwaitReady() method before using it in LocalScript, as follows:

lua
local Wisp = require(game.ReplicatedStorage.Wisp).Client
Wisp.AwaitReady()
lua
-- You can also pass the AwaitReady timeout 
-- and check whether the Wisp is initialized or not
local Wisp = require(game.ReplicatedStorage.Wisp).Client
local IsWispReady: boolean = Wisp.AwaitReady(10) -- after the time has elapsed, it will display warn in the Output
if not IsWispReady then
    error("Can't start, Wisp is not ready") -- optional
end

Fire & Connect

Wisp.Fire and Wisp.Connect are similar to the usual behavior of RemoteEvents. Let's take a closer look at Wisp.Fire and Wisp.Connect:

lua
local Wisp = require(game.ReplicatedStorage.Wisp).Client
Wisp.AwaitReady()

Wisp.Fire("player_joined", "I'm new here:)") -- will send RemoteEvent with name "player_joined"
-- there can be as many arguments as you like, and almost any type
lua
local Wisp = require(game.ReplicatedStorage.Wisp).Server

Wisp.Connect("player_joined", function(player: Player, message: string) -- the player is always passed as the first argument
    print(`{player.Name} Joined. Welcome! Player Message: {message}`)
end)

-- or:
Wisp.Once("player_joined", function(player: Player, message: string) -- listen once, auto-disconnects
    print(`{player.Name} Joined. Welcome! Player Message: {message}`)
end)
bash
- PlayerName Joined. Welcome! Player Message: I'm new here:)

The Server-Side also has additional sending functions:

lua
local Wisp = require(game.ReplicatedStorage.Wisp).Server

-- Send to all players
Wisp.FireAll(remoteName: string, ...: any)

-- Send to a list of players
Wisp.FireList(remoteName: string, players: {Player}, ...: any)

-- Send to everyone except
Wisp.FireExcept(remoteName: string, except: Player | {Player}, ...: any)

The client also has an additional method, namely Wisp.Wait():

lua
local Wisp = require(game.ReplicatedStorage.Wisp).Client
Wisp.AwaitReady()

local message: string? = Wisp.Wait("private_message") -- Infinity waiting
print("Got message:", message)

local message: boolean? = Wisp.Wait("match_start", 30) -- 30s waiting
if message then
    print("Match starting!")
else
    print("Timeout - no match found")
end

Invoke & OnInvoke

Wisp.Invoke and Wisp.OnInvoke are similar to the normal behavior of RemoteFunction.Invoke and RemoteFunction.OnInvoke, respectively:

lua
local Wisp = require(game.ReplicatedStorage.Wisp).Client
Wisp.AwaitReady()

local ServerTime: number = Wisp.Invoke("get_time")
print("Server Time:", ServerTime)
lua
local Wisp = require(game.ReplicatedStorage.Wisp).Server

Wisp.OnInvoke("get_time", function(_player: Player)
    return os.time()
end)
bash
- Server Time: 1777266546

Wisp.Invoke and Wisp.OnInvoke also accept an infinite number of arguments of almost all types, as do Wisp.Fire and Wisp.Connect.

Released under the MIT License.