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.
- Find the table assignment on the error line.
- Check the key variable actually has a value at that point.
- Guard it:
if key then myTable[key] = value end. - 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.