Connectdocs

1. Run the server

Start the Alchemy Connect server locally. By default it listens on port 3000.

Terminal
git clone https://github.com/x2neptunereal/Alchemy-Connect
cd Alchemy-Connect
npm install
npm run dev

See Server for more.

2. Execute the script

Paste this into your executor while in game. It connects, links your account and sends one batch of stats.

Luau
-- Setting
local synchronization = {
    port = 3000,
    base_url = "localhost",
    refresh_time = 10,
}

-- Services
local http: HttpService = game:GetService("HttpService")
local plr: Player = game:GetService("Players").LocalPlayer

-- Connect
local ws = WebSocket.connect(
    "ws://" .. synchronization.base_url .. ":" .. tostring(synchronization.port)
    .. "/connect/" .. tostring(plr.UserId)
)

-- Link account
ws:Send(http:JSONEncode({
    types = "link",
    data = {
        username = plr.Name,
        userid = plr.UserId,
        displayname = plr.DisplayName,
        time = os.time(),
        games = game.GameId,
    }
}))

-- Debug: print anything the server sends back
ws.OnMessage:Connect(function(msg)
    print("Debug: ", msg)
end)

-- Send stats + items
local function sendStats()
    ws:Send(http:JSONEncode({
        types = "stats",
        stats = {
            { label = "Level", value = 42 },
            { label = "Coins", value = 12000000 },
        },
        items = {
            {
                name = "Backpack",
                types = "inventory",
                data = {
                    { name = "Potion", count = 3, icon = 732391129 },
                }
            },
        }
    }))
end

sendStats()

3. Check the dashboard

Open the dashboard in your browser. Your username, display name and current game should appear, followed by the stats and items you sent.

Tip

Nothing showing? Check the executor console. The OnMessage handler prints everything the server sends back, prefixed with Debug:.