• Attempt to Index Upvalue?
    4 replies, posted
Error: [CODE]cl_hud.lua: attempt to index upvalue 'pnl' (a nil value)[/CODE] my file (whole thing) [lua]local pnl = vgui.Create('DPanel') function TestHUD() pnl:SetPos(10,10) pnl:SetSize(200,25) end hook.Add('HUDPaint','TestHUD',TestHUD) [/lua] If I'm right, I don't think this error should be spitting in console? EDIT: this is also the first time i've ever encountered this type off error... So i'm literally lost with this one xD
Don't do that in HUDPaint. HUDPaint is for the default GMod HUD element: create your panel just in the file. [code]local pnl = vgui.Create("DPanel") pnl:SetPos(10, 10) pnl:SetSize(200,25)[/code]
[code]cl_hud.lua:3: attempt to index local 'pnl' (a nil value)[/code] [lua] local pnl = vgui.Create("DPanel") pnl:SetPos(10, 10) pnl:SetSize(200,25) [/lua]
[QUOTE=Richtofen;50451771][code]cl_hud.lua:3: attempt to index local 'pnl' (a nil value)[/code] [lua] local pnl = vgui.Create("DPanel") pnl:SetPos(10, 10) pnl:SetSize(200,25) [/lua][/QUOTE] It looks like DPanel isn't registered. Where is your script located?
Forgot to mention to put it in a hook. PostInitEntity should work.
Sorry, you need to Log In to post a reply to this thread.