Don't you get a stack trace with the error? All the ones I've seen have a stack trace which gives the exact line the error occurred (at the top of the stack trace).
My usual mistakes when I cause this error are one of two things:
Code:
val = GetMisSpeled()
The function name is simply misspelled, or:
Code:
val = GetValue()
Msg = "Value = " .. val
where the function returns nil and then the string concatentation fails. I've got in the habit of doing:
Code:
Msg = "Value = ".. tostring(val)
for all strings to avoid this error (nil is turned into the "nil" string).
Another thing I've used successfully in some cases is the
pcall() function.