Gmod Lua Error List

From GMod Wiki

Jump to: navigation, search
Warning 64.pngThis page needs to be edited as it contains a list that is incomplete. It should be discussed on the talk page.
Details: None given.

This is a list of all Lua errors that you can encounter while coding stuff for Gmod, and how to fix them.

Contents

Errors

Attempt to call a nil value

Fix difficulty: Easy
Description: You tried to call a function that doesn't exist.
Possible causes:

  • Your function might be defined in another lua state. (IE. Calling a serverside function on the client.)
  • You're using a function on the wrong kind of object. (IE. Trying to call SetTarget() on a player.)
  • The function you're calling has an error in it which means it is not defined.
  • You've simply mispelt the name of the function.
    Ways to fix: Check your function calls for spelling errors. E.g. Entity.Kil will throw this error, use Entity.Kill and it'll be fixed right away!


Attempt to perform arithmetic on field '?' (a nil value)

Fix difficulty: Medium
Description: You tried to perform arithmetic (+, -, *, /) on a variable that's nil. (isn't defined yet)
Ways to fix: Make sure before you use variables you check if they're nil. Using variables which equal nil can lead to lots of errors.


Attempt to index global 'varname' (a nil value)

Fix difficulty: Easy
Description: You tried to assign an index on an array that's nil. (isn't defined yet)
Possible causes:

  • The array might be defined somewhere else, or in another lua state.
  • Spelling errors.
    Ways to fix: Make sure before you use arrays you check if they're nil.


Malformed number near 'numb'

Fix difficulty: Easy
Description: You messed up a number, somehow.
Possible causes:

  • Smashing on the keyboard while having a lua file opened in some text editor.
    Ways to fix: Remove the malformed number.


Unexpected symbol near 'symb'

Fix difficulty: Easy
Description: You typed a symbol in the code that Lua didn't know how to interpret.
Possible causes:

  • You didn't respect the syntax of a structure (IE. you forgot a 'then' after an 'if').
  • You used an uneven number of brackets or closed them at the wrong places.
  • You're using the wrong kind of operator (IE. '=' instead of '==').
    Ways to fix: Be on the look out for any characters you typed in by accident.


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox