THE ORB
Starting the studio

charinfo / metadata is nil

A character's saved details could not be read — either they had not finished loading, or that character's data is damaged.

groupsOne player breaks everythingcodeNeeds a developer

Do this first

Check whether it happens to everyone or to one player. One player means their saved data needs repairing.

bug_reportPaste your whole console instead

What it means

The player object exists but the sub-table being read is not populated. In QBCore PlayerData.charinfo holds the name and phone, PlayerData.metadata holds everything else; both are JSON columns, and a bad one comes back nil rather than empty.

What causes it

Ordered by how often it is the answer.

  1. 1

    Read before the character is selected

    Connected is not loaded. Between joining and choosing a character there is a player with no charinfo at all.

  2. 2

    The JSON column is malformed

    A truncated write (see "Data too long") leaves invalid JSON, and decoding it returns nil. That player then breaks every script until the row is repaired.

  3. 3

    A metadata key that was never initialised

    metadata.thirst on a character created before that key existed. The table is fine, the key is not.

  4. 4

    A resource restart while the player is in

    The player was loaded before your resource started, so it never saw the loaded event.

  5. 5

    Framework version differences

    Fields move between QBCore versions; a script written for one reads a key the other keeps elsewhere.

How to tell which one is yours

Check the row:

SELECT charinfo, metadata FROM players WHERE citizenid = 'ABC12345';

If either is NULL or not valid JSON, that character's data is the problem. If both look right, it is timing.

Where to look

The read, and whether the file waits for the player-loaded event.

How to fix it

Default the key, and never read at file scope:

local meta = PlayerData.metadata or {}
local thirst = meta.thirst or 100

RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
    PlayerData = QBCore.Functions.GetPlayerData()
end)

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