THE ORB
Starting the studio

table index is nil

A script tried to file something away under a name that was empty, usually a player id that was not ready yet.

groupsThat feature stops workingcodeNeeds a developer

Do this first

It usually happens while someone is still connecting. Note whether it fires on join.

bug_reportPaste your whole console instead

What it means

Something was STORED into a table under a nil key: t[k] = v where k is nil. Reading with a nil key is legal and returns nil; writing with one is an error.

What causes it

Ordered by how often it is the answer.

  1. 1

    A key that came from a lookup that failed

    cache[GetPlayerIdentifier(src)] = data where the identifier is nil because the player is not fully connected yet.

  2. 2

    A loop variable used past the end

    Storing under items[i] where i walked off the list.

  3. 3

    A field that does not exist on the object

    byJob[player.job.name] = x where the job has no name.

  4. 4

    A numeric key that became NaN

    Dividing by zero or tonumber() on something unparseable, then using it as an index. That gives "table index is NaN".

How to tell which one is yours

Print the key, not the table:

print('key =', tostring(theKey))

The line is short and the key is usually one expression, so this identifies it immediately.

Where to look

The assignment on the named line, specifically the part inside the brackets.

How to fix it

Guard the key at the point it is produced:

local id = GetPlayerIdentifier(src, 0)
if not id then return end
cache[id] = data

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