Jump to content

Gui Not closing


krgunner

Recommended Posts

hi i dont know why but i cant make this gui disappear

  
function loginWindow (  ) 
loginGui = guiCreateWindow ( 300, 250, 500, 350, "test gui", false ) 
CloseGui = guiCreateButton( 0.60, 0.90, 0.30, 0.05, "close", true, loginGui)   
showCursor ( true ) 
  
       function guiExit ( button ) 
    guiSetVisible (loginGui, false ) 
    showCursor ( false ) 
    outputChatBox ( "test" ) 
end 
  
  
addEventHandler ( "onClientGUIClick", CloseGui, guiExit ) 
         
     
addCommandHandler ( "test", loginWindow ) 
  

can ayone help?

Link to comment

You have a second function inside the first function - but only one end

Try this:

  
  
function loginWindow (  ) 
   loginGui = guiCreateWindow ( 300, 250, 500, 350, "test gui", false ) 
   CloseGui = guiCreateButton( 0.60, 0.90, 0.30, 0.05, "close", true, loginGui)   
   showCursor ( true ) 
  
    function guiExit ( button ) 
       guiSetVisible (loginGui, false ) 
       showCursor ( false ) 
       outputChatBox ( "test" ) 
    end 
end 
  

Or better, try this:

  
function loginWindow (  ) 
   loginGui = guiCreateWindow ( 300, 250, 500, 350, "test gui", false ) 
   CloseGui = guiCreateButton( 0.60, 0.90, 0.30, 0.05, "close", true, loginGui)   
   showCursor ( true ) 
 end 
  
function guiExit ( button ) 
   guiSetVisible (loginGui, false ) 
   showCursor ( false ) 
   outputChatBox ( "test" ) 
end 
  

Link to comment
  
function loginWindow (  ) 
   loginGui = guiCreateWindow ( 300, 250, 500, 350, "test gui", false ) 
   CloseGui = guiCreateButton( 0.60, 0.90, 0.30, 0.05, "close", true, loginGui)   
   showCursor ( true ) 
   addEventHandler ( "onClientGUIClick", CloseGui, guiExit ) 
 end 
  
function guiExit ( button ) 
   guiSetVisible (loginGui, false ) 
   showCursor ( false ) 
   outputChatBox ( "test" ) 
end 
addCommandHandler ( "test", loginWindow ) 
  
  

Personally I add the Event Handlers for any GUI Element in the function that it was created, as if it's done outside of a function it's loaded with the resource and sometimes (such as this case) the GUI element hasn't been created yet...

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...