THE ORB
Starting the studio

SendNUIMessage arrives empty or never arrives

A script tried to send information to its own menu and the information could not be sent, so the menu shows nothing.

groupsMenus open empty or stalecodeNeeds a developer

Do this first

Report it to the seller with this line.

bug_reportPaste your whole console instead

What it means

SendNUIMessage serialises the table to JSON and posts it to the page. Values JSON cannot express are dropped or make the whole encode fail, and a failed encode sends nothing at all — usually without an error.

What causes it

Ordered by how often it is the answer.

  1. 1

    A function in the table

    Callbacks cannot be serialised. The encode fails and the message vanishes.

  2. 2

    An entity or a vector

    GetEntityCoords returns a vector3, which is not a plain table. Send { x = c.x, y = c.y, z = c.z } instead.

  3. 3

    A cyclic table

    A table that references itself, directly or through a chain.

  4. 4

    Mixed array and map keys

    { 1, 2, foo = 'bar' } encodes to something the page will not read as either an array or an object.

  5. 5

    The page has no message listener

    The message arrives and nothing is listening for it — a different problem with the same symptom.

How to tell which one is yours

Encode it yourself first:

print(json.encode(payload))

If that errors or prints something unexpected, the payload is the problem. If it prints clean JSON, the page is not listening.

Where to look

The table passed to SendNUIMessage, and the page's message event listener.

How to fix it

-- send plain data only
SendNUIMessage({
    action = 'open',
    coords = { x = c.x, y = c.y, z = c.z },
    items = items,            -- a pure array
})

// page
window.addEventListener('message', (event) => {
    const data = event.data
    if (data.action === 'open') { /* ... */ }
})

Still stuck on your own code?

This page is what this error usually means. Paste your console into Server Fixer and it will rank everything in it and tell you what to do first, and if you would rather not touch it, ORBIE can repair the script and hand the resource back ready to drop in.

bug_reportOpen Server Fixer

Errors that travel with this one