will briggs Posted June 19, 2011 Share Posted June 19, 2011 Hey, Im making a remote that will open gates by pressing a button... This is part of my code, when i use it and press the 'gate 1' button, it gives me an errors saying attempt to index global 'movingGates' (a nil value) Heres my code local resX, resY = guiGetScreenSize() gate1 = createObject ( 971, 96.736, 1918.352, 20.694, 0, 0, 270.40 ) function makeJobGUI() end jobWindow = guiCreateWindow(resX/2-150,resY/2-200,250,350,"Military Gate Remote - Standard",false) guiSetVisible(jobWindow,false) closeButton = guiCreateButton(0.53,0.85,0.40,0.12,"Close",true,jobWindow) addEventHandler("onClientGUIClick",closeButton,function() guiSetVisible(jobWindow,false) showCursor(false) end) gate1Button = guiCreateButton(0.08,0.10,0.40,0.12,"Main Gate",true,jobWindow) addEventHandler("onClientGUIClick",gate1Button,function() if movingGates[source] then return end movingGates[source] = true moveObject(gate1, 700, 971, 96.736, 1900.352, 20.694, 0, 0, 270.4) playSoundFrontEnd(hitElement, 5) end) I cant get it working, could some one help me, after all i am ron burgandy... Link to comment
SDK Posted June 19, 2011 Share Posted June 19, 2011 The error is right, where is the table movingGates? Is it needed for something? Your script could work if you remove the if-then-else or create the table. I notice you mix serverside and clientside code in this. When clicking the button you should do a triggerServerEvent to move the gate serverside (unless you want it clientside). playSoundFrontEnd doesnt need hitElement when it's clientside. Link to comment
will briggs Posted June 19, 2011 Author Share Posted June 19, 2011 ok, they are at a51 main gate, it has no dependacys. Can u correct it for me please? 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