Selecting and deselecting element with variables

I have an element that needs to have select/unselect capability. I have created a variable called elementSelected. It’s initially set to false, and the element is unselected.

This is what I’ve done in the prototype settings:

The first time i click on element, the “elementSelected” variable switches to true, and my element changes its state to its selected state. However, once I click on the element again, nothing happens it doesn’t get unselected (its state doesn’t change).

Additionally, this is a mobile prototype, and the second click starts acting like I’m dragging instead of just clicking.

What am I doing wrong? Thanks in advance!