Okay, this may be a strange question, but what could be blocking a GUI button from being clicked? Because I have a button, and it worked, and then I added a lot of code somewhere else, and suddenly it stopped working; the script is never called, a message I put there is not displayed.
So far I checked:
- button image: is there
- GUIs in front of the button: added none since then
- game paused: never happens in the game
- button.clickable
There is literally over a dozen other buttons in the same GUI that all call the same function, and they all don't work anymore. I can still call the function through the script and it works perfectly.
When I put text on the buttons, it doesn't "click-move" like it should.
button.Clickable = true;
I think this works.
I think it doesn't (tried it nonetheless), especially since I didn't change the clickable attribute.
More suggestions?
Is the gui itself clickable?
Okay, the problem is solved and quite bizarre.
I set the button's NormalGraphic to 0 to make it invisible, then later animated the button with a view/loop. While the animation was playing, the button STILL had the size of graphic 0, which was the default 1x1 pixel clear sprite, so the button was in fact 1x1 pixel large although it appeared larger through its animation.
I changed the sprite 0 to a button-sized clear sprite, and it works now.
A better way is to set the button's .Visible to false. That way you won't have to change the size or image at all.
Yes, but because I change the NormalGraphic of the button each time it is displayed, that saves me a command line each time I do it.
Or to be honest, at that time I didn't remember that I can make buttons invisible :-[ ;) Changing the whole code is too much of a hassle now...