NexthostingLogs

Logs / Error guide / Garry's Mod

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

What the message means

An addon calls a function that doesn't exist. Most of the time the function comes from another addon or the gamemode – and that is exactly what's missing, older, or loads later.

What it looks like in the log

Loading gamemode darkrp
[ERROR] addons/hud_classic/lua/autorun/client/cl_hud.lua:112: attempt to call field 'formatMoney' (a nil value)
1. fn - addons/hud_classic/lua/autorun/client/cl_hud.lua:112
2. unknown - addons/ulib/lua/ulib/shared/hook.lua:109

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

Common causes

  • The addon was written for a different version of the gamemode (for example DarkRP functions that were renamed).
  • A library the addon requires is missing.
  • The function exists only on the client or only on the server, and the addon calls it on the wrong side.
  • Load order: the addon runs before the other one has created its functions.

How to fix it

  1. Read the name in the message (for example field 'formatMoney'): search online or in your addons for where this function comes from.
  2. Install the missing addon or update the addon that throws the error to a version for your gamemode.
  3. If the error only appears on the client (path with cl_ or /client/), it's often a file that isn't sent to the players via AddCSLuaFile.
  4. Send the addon's author the link to your log – with path, line and stack trace, they can reproduce the error right away.