hi, im trying to close a vgui made in a function in a separate function and i cant figure it out.
this is just a quick example:
[lua]
function myvgui()
local menu = vgui.Create("DFrame")--i meant local, my bad
menu:SetPos(5,5)
menu:SetSize(100, 100)
menu:SetTitle( "words here" )
menu:SetVisible( true )
menu:SetDraggable( false )
menu:ShowCloseButton( false )
menu:MakePopup()
end
function closevgui(menu) ----do i need this here???
menu:ShowVisible(false)
end
myvgui()
concommand.Add( “close”, closevgui )
[/lua]
but when i do this i get this error,
“:18: attempt to call method ‘ShowVisible’ (a nil value)”
so how do i get menu in there???
also while im at it let me ask another question, i want to run the console command “stopsounds” immediatley before i use surface.PlaySound, but when i do this the concommand carries over and stops the sound from starting. how can i do this and have it still play, should i have it wait for half a second before i run it or is there something else?
any help would be appreciated, thanks in advance