Select an object with touch (Android)

Hi. I want to get an object’s name, by tapping it on an Android touchscreen, then pass it to another script.

I use this script:

function Update () {
 
            if(Input.touchCount > 0)
            {
            var hit : RaycastHit;
            var ray : Ray = Camera.main.ScreenPointToRay (Input.GetTouch(0).position);
            if (Physics.Raycast(ray, hit, Mathf.Infinity)) {
                anotherScript.whattomove = hit.rigidbody.gameObject.name;
            }
    }
}

I checked and Unity knows when i touch the screen, but this doesn’t work.
Any help would be appreciated. Thanks

I found the error, Camera.ScreenPointToRay needs a Vector3 argument, but Input.GetTouch(0).position returns a Vector2, so a little trick is neccessary.

function Update () {

            if(Input.touchCount > 0)
            {
            var hit : RaycastHit;
            var vektor = Vector3(Input.GetTouch(0).position.x,Input.GetTouch(0).position.y,0f);
            var ray : Ray = Camera.main.ScreenPointToRay (vektor);
            if (Physics.Raycast(ray, hit, Mathf.Infinity)) {
                anotherScript.whattomove = hit.rigidbody.gameObject.name;
            }
    }
}