• [ERROR] lua/testing.lua:1: attempt to index global 'vgui' (a nil value)
    4 replies, posted
Hello everyone, im sorry for this being my first post and immediately start asking questions, but i just started lua in gmod13, did some lua in gmod12 before. now im trying to create my GUI in singleplayer, like i did in gmod 12 but i stumbled upon a small error. [B][ERROR] lua/testing.lua:1: attempt to index global 'vgui' (a nil value)[/B] since i just started after quite some time doing nothing with lua, im using the wiki to help me out. i made a folder in my gmod client directory called 'lua', and placed my script 'testing.lua' inside it and im trying to run it with the command: lua_openscript testing.lua and now it cant seem to find the vgui library? this is my code, in case i screwed up on that. Pulled it right off of the wiki so i guess the code isn't causing the failure. [CODE] local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100, 100 ) DermaPanel:SetSize( 300, 200 ) DermaPanel:SetTitle( "My new Derma frame" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() [/CODE] Can someone point me out what i am doing wrong? Many thanks, Siniq.
You are loading the code serverside. The vgui library is clientside. If you are using lua_openscript you should be using lua_openscript_cl.
Thanks for the fast reply, Lost Sandwich but that didnt fix my problem, its not showing the error anymore, but it doesnt show my vgui when calling the script. i tried to make it a function and call that function with a concommand but then it says the concommand doesnt exist? My code now: [CODE] function testframe() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100, 100 ) DermaPanel:SetSize( 300, 200 ) DermaPanel:SetTitle( "My new Derma frame" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() end concommand.Add("testframe", testframe) [/CODE] PS. This might be in the wrong section, if a mod can put it in the LUA Scripting forum, it'd be awesome! Thanks!
EDIT: Nvm... My eyes were playing me a trick there.
Okay thanks guys but I decided To Do it on My Server which Works Perfectly Fine. Less hassle. Dont know Whats Wrong with My phone But All The Uppercase letters Looks Crazy. Haha. Bye
Sorry, you need to Log In to post a reply to this thread.