Jump to content

Script error..


manve1

Recommended Posts

Hey, once again its me asking for help, but this time when i press to get skin anywhere on the GUI it just closes it

CLIENT:

function showGUI2() 
guiSetVisible(window,true) 
showCursor(true) 
end 
addEvent("showGUI2",true) 
addEventHandler("showGUI2", getRootElement(), showGUI2) 
  
function hideGUI2() 
    if (button2) then 
    guiSetVisible (window,false) 
    showCursor(false) 
end 
end 
addEvent("hideGUI2",true) 
addEventHandler("hideGUI2", getRootElement(), hideGUI2) 
addEventHandler("onClientGUIClick", getRootElement(), hideGUI2) 

SERVER:

function showGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler ("onMarkerHit",marker1,showGUI) 
  
function showGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler ("onMarkerHit",marker2,showGUI) 

Link to comment
  
  
function hideGUI2() 
    if (button2) then 
    guiSetVisible (window,false) 
    showCursor(false) 
end 
end 
addEvent("hideGUI2",true) 
addEventHandler("hideGUI2", getRootElement(), hideGUI2) 
addEventHandler("onClientGUIClick", getRootElement(), hideGUI2) -- See here you put getRootElement(), if you are going to do it like this then: 
  
  
function hideGUI2() 
    if source == button2 then 
    guiSetVisible (window,false) 
    showCursor(false) 
end 
end 
addEvent("hideGUI2",true) 
addEventHandler("hideGUI2", getRootElement(), hideGUI2) 
addEventHandler("onClientGUIClick", getRootElement(), hideGUI2)  
  

Try that, just copy the bottom one not the top.

Link to comment
addEventHandler("onClientGUIClick", getRootElement(), hideGUI2) 

getRootElement() is not a GUI element, it is the root. You need to define the GUI element over root, and remember to add "false" argument in the end, so it only accepts the GUI element you entered.

So the fix would be:

function hideGUI2() 
    guiSetVisible (window,false) 
    showCursor(false) 
end 
addEventHandler("onClientGUIClick", button2, hideGUI2, false) 

Simpler way is this:

function showGUI2() 
    guiSetVisible(window, true) 
    showCursor(true) 
end 
  
addEventHandler("onClientGUIClick", button2, function() showCursor(false) guiSetVisible(window, false) end, false) 

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...