Jump to content




Loading an API, attempt to index ? (a nil value)


  • You cannot reply to this topic
2 replies to this topic

#1 Adamski1997

  • Members
  • 8 posts

Posted 10 May 2017 - 11:23 PM

Hi,

below is the simplified code that is causing the issue (I don't believe you need any more code than this, there is a lot of it!)

main:

os.loadAPI("GUI")
function main()
   --Lots of code
   local username, password = GUI.runLogin("")
end
main()

GUI:
--Some code
function runLogin(msg)
   --Lots of code
   return username, password
end

The error I get seems to occur on the compiler pass, since no print statements in either the GUI or main files get printed before the error is thrown.

The exact error I get is: "main:29: attempt to call index ? (a nil value)" (In the minified example I've given you the one an only line in the main function is the one that throws the error)

Any idea how to fix this? I don't know what is wrong with the way I've done this..

(Yes both main and GUI are in the exact same directory on the computer)

Edited by Adamski1997, 10 May 2017 - 11:26 PM.


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 10 May 2017 - 11:58 PM

First, I would figure out if GUI is actually loading. os.loadAPI returns a boolean value stating whether or not the API has been loaded.

#3 Adamski1997

  • Members
  • 8 posts

Posted 11 May 2017 - 12:07 AM

Well for some reason adding the code to print if the API is loaded or not fixed it. Even after reverting the code back to its original state it now works, so no idea what solved it but thanks!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users