Getting Started
Configuration
All connection settings live in one table at the top of the script.
Settings
Luau
-- Setting
local synchronization = {
port = 3000,
base_url = "localhost",
refresh_time = 10,
}| Field | Type | Description |
|---|---|---|
port | number | Port the server listens on. Default 3000. |
base_url | string | Host of the server, without protocol. Use localhost when the server runs on the same PC. |
refresh_time | number | Seconds between stats updates when you send them in a loop. See Stats → Refreshing. |
Services
The script needs these Roblox services:
Luau
local http: HttpService = game:GetService("HttpService")
local rep: ReplicatedStorage = game:GetService("ReplicatedStorage")
local plr: Player = game:GetService("Players").LocalPlayerHttpServiceencodes messages as JSON.Players.LocalPlayergives the account info and theUserIdused in the URL.
Connecting
The WebSocket URL is built from the settings plus the player's UserId:
URL
ws://{base_url}:{port}/connect/{UserId}Luau
local ws = WebSocket.connect(
"ws://" .. synchronization.base_url .. ":" .. tostring(synchronization.port)
.. "/connect/" .. tostring(plr.UserId)
)Heads up
The UserId in the URL identifies the connection. Always use plr.UserId, so it matches the userid you send in the link message.
Testing the connection
Plain strings can be sent too, which is handy for a quick check. Listen on OnMessage to see what the server replies:
Luau
ws:Send("Connected!")
ws.OnMessage:Connect(function(msg)
print("Debug: ", msg)
end)