freudo Posted February 20, 2015 Posted February 20, 2015 Hi guys I write this code: addEventHandler("onClientResourceStart", resourceRoot, function() onoff = guiCreateStaticImage(578, 290, 138, 34, "img/off.png", false) showCursor(true) end ) function click() if (source == onoff) then guiStaticImageLoadImage(onoff, "img/on.png") elseif (source == onoff) then guiStaticImageLoadImage(onoff, "img/off.png") end end addEventHandler("onClientGUIClick",root,click) I click onoff button and load on button again ı want click and load on button pls help WOC-DD Destruction Derby -Level system -Clan system -Topwins -Event system for EXP -Podium with animation And more
Dealman Posted February 20, 2015 Posted February 20, 2015 The first if statement will always be true, it will never run the 2nd one. You'll have to assign a variable; local isButtonOn = false; function click() if (source == onoff and isButtonOn == false) then guiStaticImageLoadImage(onoff, "img/on.png") elseif (source == onoff and isButtonOn == true) then guiStaticImageLoadImage(onoff, "img/off.png") end end addEventHandler("onClientGUIClick",root,click) If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
freudo Posted February 20, 2015 Author Posted February 20, 2015 thank you. WOC-DD Destruction Derby -Level system -Clan system -Topwins -Event system for EXP -Podium with animation And more
Dealman Posted February 20, 2015 Posted February 20, 2015 Just noticed I forgot to update the variable too, my bad; local isButtonOn = false; function click() if (source == onoff and isButtonOn == false) then guiStaticImageLoadImage(onoff, "img/on.png") isButtonOn = true elseif (source == onoff and isButtonOn == true) then guiStaticImageLoadImage(onoff, "img/off.png") isButtonOn = false end end addEventHandler("onClientGUIClick",root,click) But maybe you figured it out already If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
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