glowdemon1 Posted August 22, 2013 Share Posted August 22, 2013 function onMachineClick(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, element) if element and getElementType( element ) == "object" and button == "right" and state == "down" and getElementModel(element) == 955 then vendingWindow = guiCreateWindow(0.375,0.375,0.25,0.25,"Vending machine by freshhh", true) cancelButton = guiCreateButton(0.7,0.1,0.2,0.1,"Cancel", true) buyButton = guiCreateButton(0.9,0.1,0.2,0.1,"Purchase", true) end end function shutDownGUI(button, state) if button == "left" and state == "up" then guiSetVisible (vendingWindow, not guiGetVisible ( vendingWindow ) ) showCursor(false) end end addEventHandler("onClientClick", getRootElement(), onMachineClick) addEventHandler("onClientGUIClick", cancelButton, shutDownGUI, false) Whenever I click the cancel button, the GUI doesn't go away. I'm new to GUI's, so any help ? Link to comment
TAPL Posted August 22, 2013 Share Posted August 22, 2013 You was add the event before the button created. function onMachineClick(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, element) if element and getElementType( element ) == "object" and button == "right" and state == "down" and getElementModel(element) == 955 then vendingWindow = guiCreateWindow(0.375,0.375,0.25,0.25,"Vending machine by freshhh", true) cancelButton = guiCreateButton(0.7,0.1,0.2,0.1,"Cancel", true) addEventHandler("onClientGUIClick", cancelButton, shutDownGUI, false) buyButton = guiCreateButton(0.9,0.1,0.2,0.1,"Purchase", true) end end addEventHandler("onClientClick", getRootElement(), onMachineClick) function shutDownGUI(button, state) if button == "left" and state == "up" then guiSetVisible (vendingWindow, not guiGetVisible ( vendingWindow ) ) showCursor(false) end end Link to comment
glowdemon1 Posted August 22, 2013 Author Share Posted August 22, 2013 Oooh, thanks alot. Link to comment
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