WebSocket.connect — open a live WebSocket
ws-connectOpens an outbound WebSocket from the active Roblox client to a live game endpoint, returning an id for send, receive, and close actions.
Instructions
WRITES LIVE GAME STATE — opens a real outbound WebSocket from the client via WebSocket.connect(url). The live socket is parked in a getgenv registry keyed by an integer id (returned as id); use that id with ws-send, ws-receive, ws-close, and ws-list. On connect, ws.OnMessage is wired into a capped (200-frame) ring buffer and ws.OnClose flips the entry's open flag to false, so inbound frames accumulate server-side until you fetch them. Requires the WebSocket library (type(WebSocket)=='table' with WebSocket.connect) — both are type-guarded and the connect is pcall-wrapped, returning { error } when missing or on failure. Returns { id, url } or { error }. Signature: { url: string, threadContext: number? }. Phase: act; cost=medium; idempotency=contextual-write. Requires: active-client, explicit-mutation-approval. Capabilities: WebSocket. Produces: created-handle. Verify with: ws-list. Safety: MUTATING; performs external network or socket I/O. On failure: inspect tool-schema for exact fields, defaults, constraints, and an invocation example.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The WebSocket URL to connect to, e.g. 'ws://127.0.0.1:8080' or 'wss://example.com/socket'. | |
| threadContext | No | Optional Roblox thread identity for this call; omit it to use the server default. |