NextGenRP Posted April 30, 2012 Posted April 30, 2012 (edited) Hey im trying to close a GUI, function GUIFunction() -- other gui elements are here that work fine, Including a button that works fine too. closeButtonn = guiCreateButton(sWidth-697,sHeight-425,sWidth-981,sHeight-744,"Close",false,registerWindow) addEventHandler("onClientGUIClick", closeButtonn, closeRegiWindow, false) end function closeRegiWindow() destroyElement(registerWindow) --I want to destroy the window, If the player clicks on the button that opened it it will run the GUIFunction again. end It just acts as if im not clicking the button when i am and there is no errors in the debug. Edited April 30, 2012 by Guest
Guest Guest4401 Posted April 30, 2012 Posted April 30, 2012 Line 5 : CloseRegisterrWindow Line 8 : closeRegisterrWindow Both should be of the same case...
NextGenRP Posted April 30, 2012 Author Posted April 30, 2012 Yeah i noticed that but it still doesn't work
Wei Posted April 30, 2012 Posted April 30, 2012 closeButtonn = guiCreateButton(sWidth-697,sHeight-425,sWidth-981,sHeight-744,"Close",false,registerWindow) function closeRegisterrWindow() guiSetVisible(registerWindow, false) end addEventHandler("onClientGUIClick", closeButtonn, closeRegisterrWindow) I think...
NextGenRP Posted April 30, 2012 Author Posted April 30, 2012 The button isn't created until the GUIFunction creates the GUI, So i can't add an event handler to a button that doesn't exist? Im not sure but i don't think so, I see you put the handler under the function i want to use i moved the function above the GUIFunction and it seems to work thanks
Smart. Posted April 30, 2012 Posted April 30, 2012 I wouldn't suggest doing this, I would suggest using: function randomFunction(button) if (button) ~= "left" then return end if (source == closeButtonn) then guiSetVisible( yourGUIElement, false) elseif ( source == someGUIElement ) then --something end end addEventHandler("onClientGUIClick", resourceRoot, randomFunction, true)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now