World External · Luau VM

WebSockets

Open persistent, event-driven connections to a WebSocket server.

Overview

A persistent two-way connection, for when polling an HTTP endpoint is the wrong shape — a remote control panel, a live feed, anything the far end needs to push.

A control channel
local socket = WebSocket.connect("ws://localhost:8080")

socket.OnMessage:Connect(function(message)
    if message == "noclip on" then
        set_noclip(true)
    end
end)

socket.OnClose:Connect(function()
    warn("socket closed")
end)

socket:Send("external ready")

Reference