• Unable to remove Derma Frame
    4 replies, posted
Hi, I'm getting a error when I try to make a Derma Fram, and then try and remove the frame. Here is the error I'm getting [CODE] [ERROR] addons/nodecore/lua/autorun/dankmemes.lua:127: attempt to index global 'panel2' (a nil value) 1. DoClick - addons/nodecore/lua/autorun/dankmemes.lua:127 2. unknown - lua/vgui/dlabel.lua:232 [/CODE] Here is the code that is giving the error: [CODE] fbtn.DoClick = function() local panel2 = vgui.Create("DFrame") panel2:SetTitle("") panel2:ShowCloseButton( false ) panel2:SetSize( 10, 10 ) panel2:Center() panel2:SetSizable( false ) function panel2:Paint(w, h) draw.RoundedBox(3, 0, 0, w, h, Color(0, 0, 255, 255)) end end ffbtn.DoClick = function() panel2:Remove() end [/CODE]
You're declaring panel2 locally inside a function and trying to remove it outside of that function, when the value panel2 no longer exists.
Why are you creating panel2 in fbtn's DoClick function? [CODE] fbtn.DoClick = function() local panel2 = vgui.Create("DFrame") -- What [/CODE] This might work: [CODE] local panel2 = vgui.Create("DFrame") panel2:SetTitle("") panel2:ShowCloseButton( false ) panel2:SetSize( 10, 10 ) panel2:Center() panel2:SetSizable( false ) function panel2:Paint(w, h) draw.RoundedBox(3, 0, 0, w, h, Color(0, 0, 255, 255)) end ffbtn.DoClick = function() panel2:Remove() end [/CODE] [editline]29th October 2017[/editline] ninja'd
Well I need it to be removed and then created again because I'm making a small dot in the center of the screen as a cross hair.
define panel2 outside of the fbtn DoClick function
Sorry, you need to Log In to post a reply to this thread.