lua_openscript and lua_openscript_cl not working

Whenever I try to run a lua file using either lua_openscript or lua_openscript_cl. In single player, or off a dedicated server console. i get

attempt to index global ‘TOOL’(a nil value)

attempt to index global ‘ENT’(a nil value)

Pretty much any of the first globals in any lua.

It will not parse a lua file, unless I restart either the dedicated server or my Garrysmod. Im trying to learn lua programing, and having to restart gmod or the server everytime is really annoying : /

Am I doing something wrong?
Does anyone have anything about why it would be doing this?

Thanks in advance :slight_smile:

Well, first off this is the wrong section. Second off we need to see your code to help you!

It looks like you’re trying to open stools and sents with lua_openscript. You cannot do this as far as I know.
Use lua_reloadents.

You could try putting your stool in garrysmod/garrysmod/lua/weapons/gmod_tool/<FILENAME.lua

I think any lua file in the lua/weapons vdirectory is passed along a TOOL var to work with, it’s worth a try. I can’t try it right now though, not near computer with gmod.

With lua_openscript you can only open scripts that are stored in lua/ directory. Not addons, the main lua/ folder.
For loading ENTs there is an addon. If you can use SVN heres the link.

You can still open lua scripts that are in an addon, you just try to open it as if it were in the lua folder.

Thanks for the help guys, It’s much easier to work on things now. :slight_smile: