• Derma not displaying with concommand.Add
    4 replies, posted
I'm trying to teach myself Lua and I tried to create a test Derma script and it won't seem to work with console commands. I'm not sure how I'm supposed to fix an error such as this: [code][lua\dermaclosebutton.lua:22] attempt to index global 'frame' (a nil value) [/code] Here's the function I used on line 22 [code]function displayOn() frame:SetVisible(true) end[/code]
frame is not defined. It would be something like... [lua] local frame = vgui.Create("") [/lua]
It's already defined. Here's the first two lines of the Lua. [code]function create_frame() local frame = vgui.Create("DFrame") [/code]
Yes, well, your creating the variable frame inside the function create_frame() which means the variable is only available inside that function. Move local frame above function create_frame() and change local frame = vgui.Create("DFrame") to frame = vgui.Create("DFrame") google variable scope and read about that.
That did the trick! Thanks!
Sorry, you need to Log In to post a reply to this thread.