Quick help with function

I need help with this button function…

local Clicker = vgui.Create("DButton", hello)
    Clicker:SetText("I always wanted to be a cop! :D")
    Clicker:SetSize(200, 35)
    Clicker:SetConsoleCommand("say", "/cp")
	Clicker:SetFont( "GModToolName" )
	Clicker:SetTextColor( Color( 252, 252, 252 ) )
	Clicker.Paint = function()
    surface.SetDrawColor( 112, 112, 112 )
    draw.RoundedBox( 8, 0, 0, Clicker:GetWide(), Clicker:GetTall(), Color( 0,0,0,200 ) )

so when you click on button it answers with say command “/cp” and with function

Clicker.DoClick = function()
    hello:Close() end

I know its something with if =, but sorry i am not long in this waters.
Thanks for help in advance.

Im not sure what your problem is. What is wrong with this? Do you get an error?

Well when you press the button it makes you a cp but it doesnt close the panel, so i added the function for closing panel the function in upper message but it just close the panel and not make you a cp.


Doesnt work


Thank Robotboy.

Here’s an example of an NPC where you press USE on and it’ll open a menu with 2 buttons. Join team 2, and close…


Simple example of npc, shows how to set up a basic npc ( I’ll be adding a few other examples where this system is added on to such as dynamic vgui screens based on npc, or teams, etc… )


Also, there is a dev function in there. dev_spawnent x where x is where you’d type the entity name you want to spawn ( it’ll spawn 5 feet or so in front of you, taken from: https://dl.dropboxusercontent.com/u/26074909/tutoring/entities/spawn_entity_in_front_of_player_by_calc_size_of_object.lua.html )

@Acecool on make so on your join team 2 button you close the panel after pressing the button. So you join team 2 and close the panel.

What are you asking for?

Yeah, to make it close when you “join” change

	_bjoin.DoClick = function( )
		net.Start( "npc_jointeam_cl_to_server_join_team" );
		net.SendToServer( );

to include the line included here

	_bexit.DoClick = function( )
		_panel:Remove( );

which turns it into

	_bjoin.DoClick = function( )
		net.Start( "npc_jointeam_cl_to_server_join_team" );
		net.SendToServer( );
		_panel:Remove( );