NexthostingLogs

Logs / Error guide / Garry's Mod

Garry's Mod: “attempt to index a nil value”

What the message means

An addon wants to access something – a table, a player, a setting – that doesn't exist. In Lua, “nothing” is called nil, and you can't access nil. The line in the error gives the file and line number where this happens.

What it looks like in the log

Loading gamemode darkrp
[DarkRP] Loaded 34 jobs, 18 shipments, 6 categories
[ERROR] addons/vehicle_shop/lua/vshop/sv_spawn.lua:58: attempt to index a nil value
1. SpawnCar - addons/vehicle_shop/lua/vshop/sv_spawn.lua:58
2. func - addons/vehicle_shop/lua/vshop/sv_net.lua:21
3. unknown - lua/includes/extensions/net.lua:38

Excerpt from an example log, marked the way the analysis marks it.

Common causes

  • An addon this one depends on is missing or loads later (for example a library or a pack's base addon).
  • The addon was written for a different version of your gamemode, for example for old DarkRP.
  • An entry in the configuration file is missing or misspelled (job, category, vehicle).
  • The addon accesses a player or entity that no longer exists (the player left the server).
  • With “attempt to index field 'xy'” or “global 'xy'”, the name of what's missing is right in the message.

How to fix it

  1. Read the path: the folder after addons/ is the addon that throws the error. The analysis shows it to you directly.
  2. Look at the stack trace below it: often the addon is called by another one – the second one is then the real trigger.
  3. Check the addon's page (Workshop or vendor) for which other addons it needs, and install them.
  4. Check the addon's configuration file, especially entries you changed shortly before.
  5. If that doesn't help: remove the addon briefly, check whether the error disappears, and send the author the link to your log.