Lua Error

Sorry, just started lua. I am following this

And I made a file in garrysmod/lua called lol.lua with this inside.

local Form = vgui.Create( "DFrame" )
Form:SetPos( 5, 5 )
Form:SetSize( 300, 150 )
Form:SetTitle( "Inventory" )
Form:SetVisible( true )
Form:SetDraggable( false )
Form:ShowCloseButton( true )

Form.Paint = function()

Label = vgui.Create( "DLabel", Form )
Label:SetText( "I am a label" )

Then I run it from console using lua_openscript lol.lua and I get this error:

[ERROR] lua/lol.lua:1: attempt to index global 'vgui' (a nil value)
  1. unknown - lua/lol.lua:1

Sorry for the retardness.

You are running it serverside.

( Means you gotta use lua_openscript_cl lol.lua, which will work only after you do sv_allowcslua 1, or put your file into lua/autorun/client/whatever.lua so it is ran automatically and all changes will be applied automatically )

Oh thanks :slight_smile:

Thanks for explaining it.
I wasn’t really feeling like doing it :3

Lazy ass :3