How to create a button

Hi, i wanted to create a Button in unity which creat’s an object when i press it i tried:

if(Input.touchCount >=1) { 
var touch: Touch = Input.touches[0]; 
if(touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) { 
Instantiate(basis,pos.position,pos.rotation);} 
else {Instantiate(basis,pos.position,pos.rotation);
} 
} 
} 

But with this it doesnt stop creating objects, and it isnt a button at all, would be really thankful if anyone could help me.

Hi! Surely you’ve mistyped your script, because as we can read it, it basicaly says: if this, do that, and if not, well… do it as well! No wonder you’re instantiating lots of objects.

Yes I know,but the problem is that I don't know how to stop it, because stop/end don't work.

I tried `else {return Instantiate(basis,pos.position,pos.rotation);` but this also wont work.

delete this part
“else {Instantiate(basis,pos.position,pos.rotation);”