Well, your code does exactly what it is supposed to do.
It takes a X as target and will move your object until it reached that destination.
What you are wanting is far simpler.
You want, on click, to change the direction of the object.
So by default have it going in a direction.
On touch, change the value of the direction.
The object is now moving the other direction.
It gives :
When dir is = 0, move the object to the right.
When dir is = 1, move the object to the left.
On touch, modify the value of dir so that it is either 0 or 1.
thanks a lot bro you really help me there you don't even know man thanks a lot really an truly