How can I perform a click function?

Although slightly different to what you’re doing, this may help work out how to prevent activating a button in certain circumstances: