• Trouble with DoClick
    6 replies, posted
Hello, I created a custom menu with a custom close button and when I open it and closes too fast it wants to close more and say in the console: [ERROR] addons/mymenu/lua/autorun/client/cl_mymenu.lua:91: attempt to call method 'Close' (a nil value)   1. DoClick - addons/mymenu/lua/autorun/client/cl_mymenu.lua:91    2. unknown - lua/vgui/dlabel.lua:232 my code at line 91 : MyMenuClose.DoClick = function(self)  MyMenu:Close() end 
Try this: self:Close()
He needs to close the window, not the button. Could you a bit more of your vgui code? specfically the frame and button
here is : local MyMenuClose = vgui.Create( "DButton", MyMenu )  MyMenuClose:SetSize( 15, 15 )  MyMenuClose:SetPos(  MyMenuClose:GetWide() - 25, 5 )  MyMenuClose:SetText( "X" )  MyMenuClose:SetTextColor( color_black )  MyMenuClose.Paint = function( self, w, h )  end  MyMenuClose.DoClick = function(self)  MyMenu:Close() end  end 
https://i.gyazo.com/ecaac17a662b33ebdb4f701c06c67b83.png
Use Remove()
Sorry, you need to Log In to post a reply to this thread.