xTravax Posted August 1, 2014 Share Posted August 1, 2014 (edited) hi this code isnt working function openGui() if guiGetVisible ( GUIEditor_Window[1] ) then -- line 100 guiSetVisible ( GUIEditor_Window[1], false ) showCursor(false) guiSetInputEnabled(false) else guiSetVisible ( GUIEditor_Window[1], true ) -- line 105 showCursor(true) guiSetInputEnabled(true) end end bindKey("F6","down",openGui) line 100: attemp to index global 'GUIEditor_Window' a nil value please help im new to gui Edited August 1, 2014 by Guest Link to comment
TAPL Posted August 1, 2014 Share Posted August 1, 2014 Put this on the top of the script. GUIEditor_Window = {} Link to comment
xTravax Posted August 1, 2014 Author Share Posted August 1, 2014 i got warnings in line 100 and 105 bad argument guiGetVisible and guiSetVisible (expected gui-element at argument 1,got nil) edit: nvm i fixed it by myself,thanks Link to comment
xTravax Posted August 1, 2014 Author Share Posted August 1, 2014 just one more thing why do i keep getting error expected element at argument 2 but got nil? function colt ( ) outputChatBox("Colt-45",localPlayer) end addEventHandler ( "onClientGUIClick", GUIEditor.button[1], colt, false ) Link to comment
TAPL Posted August 1, 2014 Share Posted August 1, 2014 Add the event after you create the button not before. Also the function outputChatBox client side doesn't require player element. Link to comment
xTravax Posted August 2, 2014 Author Share Posted August 2, 2014 it's already under it i have first function which guieditor resource made and my function is already under that function so button is already created but when i click on it it doesnt output anything as it gives that error - expected element at argument 2 but got nil Link to comment
TAPL Posted August 2, 2014 Share Posted August 2, 2014 I guess you created the button inside the event onClientResourceStart and added the event onClientGUIClick outside the event onClientResourceStart which mean the button won't get create until the resource started fully and you tried to attach the button to the event onClientGUIClick before the resource started fully so that you get the error. Link to comment
xTravax Posted August 2, 2014 Author Share Posted August 2, 2014 yeah correct but, how do i fix this then? Link to comment
Anubhav Posted August 2, 2014 Share Posted August 2, 2014 function colt ( ) outputChatBox("Colt-45") end addEventHandler ( "onClientGUIClick", GUIEditor.button[1], colt, false ) Link to comment
xTravax Posted August 2, 2014 Author Share Posted August 2, 2014 function colt ( ) outputChatBox("Colt-45") end addEventHandler ( "onClientGUIClick", GUIEditor.button[1], colt, false ) i dont understand how would this fix the problem the problem is it says (for addEventHandler: )element on argument 2 is nil - GUIEditor.button[1] <-- that one and that button is already created in window but it still says that its nil Link to comment
TAPL Posted August 2, 2014 Share Posted August 2, 2014 yeah correct but, how do i fix this then? Simply create the button outside the event onClientResourceStart but then you will need also to create the window outside the event because you are attaching the button to the window, Another option would be adding the event onClientGUIClick inside the event onClientResourceStart. Link to comment
Max+ Posted August 2, 2014 Share Posted August 2, 2014 -- Like this , GUIEditor_Window = {} addEventHandler ( 'onClientGUIClick', resourceRoot, function ( ) if ( source == GUIEditor.button[1] ) then outputChatBox("Colt-45", 255, 255, 0 ) end end ) ----- bindKey("F6","down", function ( ) if guiGetVisible ( GUIEditor_Window[1] ) == true then guiSetVisible ( GUIEditor_Window[1], false ) showCursor(false) guiSetInputEnabled(false) else guiSetVisible ( GUIEditor_Window[1], true ) showCursor(true) guiSetInputEnabled(true) end end ) Link to comment
xTravax Posted August 2, 2014 Author Share Posted August 2, 2014 ok thanks tapl and max Link to comment
Max+ Posted August 2, 2014 Share Posted August 2, 2014 ok thanks tapl and max You'r welcome 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