Help with a Toggle-able Panel!

I was wondering how I would go about making a panel on a Dframe be toggled by a separate button on the same Dframe. Ex, Pressing a button once and it brings up a panel on the Dframe, then pressing it again to make it dissapear.

Here is my code for the Panel, If needed I guess.

local CDMP1 = vgui.Create( "DPanel", FCDM ) 
	CDMP1:SetSize( 300, 0 ) 
	CDMP1:Dock( LEFT )

And I don’t know if the button code is needed, so here it is:

local CDMBD1 = vgui.Create( "DButton", CDMP1 ) 
	CDMBD1:SetPos( 20, 100)
	CDMBD1:SetSize( 250, 30 )
	CDMBD1:SetText( "ARRA" )
	CDMBD1.Paint = function()
		draw.RoundedBox(1, 0, 0, CDMBD1:GetWide(), CDMBD1:GetTall(), Color(64,64,64,255))
	function CDMBD1:DoClick()


Thanks in advance.


I changed the DoClick function to this:

function CDMBD1:DoClick()
 CDMP2:SetVisible( true )

Then I get this error until I close the DFrame

[ERROR] lua/derma/derma_gwen.lua:21: bad argument #3 to 'SetDrawColor' (number expected, got no value)
  1. SetDrawColor - [C]:-1
   2. Normal - lua/derma/derma_gwen.lua:21
    3. unknown - lua/skins/default.lua:315

and the panel doesn’t show.

[editline]23rd September 2017[/editline]

Okay, I figured out I had an error with the color and thats why it kept producing the error, it’s fixed now but the panel shows up before I press the button.

[editline]23rd September 2017[/editline]

I believe I have solved my issue, as I needed to set the Panel’s visibility to false first.