Guides

Troubleshooting

The errors you will meet most often and how to fix them.

ErrorCauseFix
attempt to call a nil valueThe function does not exist (typo or wrong namespace).Check the spelling in this page.
attempt to index a nil valueentity.get_local_player() (or a lookup) returned nil.Guard it: local me = entity.get_local_player() if not me then return end.
drawing is only available inside paint / present_queue callbacksA render.* call outside a drawing callback.Draw from events.present_queue, events.menu or a custom control.
the user command is only available inside create_move callbackscmd used outside create_move.Keep command code inside events.create_move.
the script took too longA callback ran longer than 300 ms.Optimize loops, cache results, spread work over frames with Delay.
unexpected symbol near '|' (or '&', '~')Bitwise operators do not exist in LuaJIT.Use bit.bor, bit.band, bit.bnot.
attempt to index global 'ffi' (a nil value)The script uses the FFI but Allow Lua FFI is off (default).Turn it on in the Settings tab, or use memory.* / entities.* which need no FFI.
attempt to index field 'open' (a nil value) on ioio.open, io.lines, os.execute and friends are removed.Use file.read, file.write, file.append, file.list.
bytecode loading is disabledA precompiled chunk was passed to load / loadstring.Load readable Lua source.
a field reads a strange valueThe schema had no type and the name prefix guessed wrong.Read it with accessor:get_as("uint8") or memory.read.

Debugging tips#

  • print() output and errors go to the console sub tab of the Lua tab and under the editor.
  • Check in the Lua tab runs a syntax check; the editor also checks while you type.
  • Wrap risky code with pcall and print the error: local ok, err = pcall(fn) if not ok then print(err) end. debug.traceback only exists when Allow Lua FFI is on.