Close VGUI with DButton?

I was wondering how you would close a vgui when you press a button? I made a button, and I want it when it’s pressed, it sets the player to that team, and closes the vgui too. Here is the code, add it in there if you would:
[lua]
local team2 = vgui.Create( “DButton”, tc2 )
team2:SetSize( 100, 75 )
team2:CenterHorizontal()
team2:SetText( “Sharp Shooters” )
team2.DoClick = function()
RunConsoleCommand( “sn_team2” )

end
end
[/lua]

team2:Close()

[LUA]local team2 = vgui.Create( “DButton”, tc2 )
team2:SetSize( 100, 75 )
team2:CenterHorizontal()
team2:SetText( “Sharp Shooters” )
team2.DoClick = function()
RunConsoleCommand( “sn_team2” )
team2:Close()
end
end[/LUA]

Doesn’t work.


cl_init.lua:53: attempt to call method 'Close' (a nil value)

panel_your_button_is_on:Close()

Im confused?

[lua]tc2:Close()[/lua]

Ah, thanks.