How to read Gmod Errors?

I have been working with gmod lua for years but no one has ever told me how to read gmod lua errors properly


I didn’t find anything with a search online. Does anyone have a link or can tell me?

Things like what does the 2,3,4 errors mean?

I believe the first line is the main point where the error occurred.

What do things like include - [C]:-1 on line 2 mean?

If anyone has the time to tell me that would be most appreciated!

That’s the file that errored.

The 626 is the line number that the error occurred on.

[C]:-1 means that the error is not in lua code. It occurred in an engine call (somewhere in C code.)
In this case, it means the function that called the upper stacks is in C code.

Each of the numbers counting up refer to the Stack Trace.

As to the stack trace, cl_init.lua ran the function include on the file sh_player.lua, which is the origination of the actual error.

It shows you what code was called in what order to help you debug why something isn’t working. For example, you might have a functions A and B that both call function C. Knowing that function B is feeding invalid information into C is useful so that you do not waste time looking at A.

As for the actual error, on line 626 of sh_player.lua, AddChatCommand isn’t defined so it returns as a nil value.