Jump to content

Script Error


manve1

Recommended Posts

I have got a slight one of the annoying problems when you can't find problem in the script.

My problem is when i click button "close" it doesn't close.

gui = guiCreateWindow( 0.3, 0.2, 0.4, 0.6, 'Da window', true ) 
close = guiCreateButton( 0.1, 0.75, 0.8, 0.15, 'Close', true, gui ) 
  
addEventHandler('onClientGUIClick', close, 
function( p ) 
if ( localPlayer == p ) then 
guiSetVisible( gui, false ) 
showCursor( false ) 
end 
end, false 
) 

NOTE: By my knowledge using 'if ( localPlayer == p ) then' it will make it work only to the person who clicked the button.

Link to comment
NOTE: By my knowledge using 'if ( localPlayer == p ) then' it will make it work only to the person who clicked the button.

Wrong. When a code is client-side, it will only execute the function or whatever you're doing to the client who's executing it. Whenever someone makes a command client-side, everything in the command handler's function will only be execucted for the player. This can be seen in outputChatBoxes client-side, there's no element argument, because it will automatically be executed to the player executing it.

Secondly, there's no element argument in onClientGUIClick event, as I said in the above text.

Client-side

local gui = guiCreateWindow(0.3, 0.2, 0.4, 0.6, "Da window", true) 
local close = guiCreateButton(0.1, 0.75, 0.8, 0.15, "Close", true, gui) 
  
addEventHandler("onClientGUIClick", close, function() guiSetVisible(gui, false) showCursor(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...