How do I set up a GUITexture as a button? (Java Script)

I added GUITexture by going to Game object>>Create Other>>GUI Texture and added its texture in the inspector what I want now is when the user touches (Game is for android and IOS) that GUITexture to move cube up I tried this code

var up : GUITexture;
var player : Rigidbody2D;

function Update () {

for (var evt : Touch in Input.touches) {

var HitTest1 = up.HitTest(evt.position);

if (evt.phase == TouchPhase.Began) {

if(HitTest1){

player.rigidbody2D.AddForce(Vector2(-2,0));

fireButton.enabled = false;

} 
} 
} 
}

but it didn’t work :frowning: what can I do ?

I tried this code blew as well but didn’t work can some one tell me why

var up : GUITexture;

function Update () {

if(Input.touchCount > 0){
var touch: Touch = Input.touches[0];
if(touch.phase==TouchPhase.Began&&up.HitTest(touch.position)){
Debug.Log("Touch working");
}
 }
  }

for most devices (IOS && Android) the OnMouseDown function would work (on touch screens)

OnMouseDown

Hi, this tutorial was really helpful for me. It is in C#, though.