ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
Luacrash

table index is nil

Also seen as: table index is nil Lua invalid table key nil

What causes it

Your code tried to use nil as a key when writing to a table (e.g. myTable[key] = value where key is nil). Usually the key variable wasn't set.

How to fix it

Ensure the key isn't nil before assigning to the table.

  1. Find the table assignment on the error line.
  2. Check the key variable actually has a value at that point.
  3. Guard it: if key then myTable[key] = value end.
  4. Trace back why the key ended up nil (often a missing return or bad lookup).

Related errors

Related guides

Still stuck? We can help.

Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.