Collision not working.

Hi, I’ve spent about 3 hours trying every single possible way of doing this but nothing seems to work.
I have an object with a mesh collider and rigidbody.
Iam moving this object on Z with 2 touch controls (android platform)
Script for moving:

var leftcontrol : GUITexture;
var rightcontrol : GUITexture;


function awake(){
	leftcontrol = GameObject.Find("GUIleft").guiTexture;
	leftcontrol = GameObject.Find("GUIright").guiTexture;
}


function Start () {

}

function Update () {

		for (var touch : Touch in Input.touches)
		{
			if (touch.phase == TouchPhase.Stationary && leftcontrol.HitTest (touch.position)){
				transform.position.z -= 10;
			
		}}
		for (var touch : Touch in Input.touches)
		{
			if (touch.phase == TouchPhase.Stationary && rightcontrol.HitTest (touch.position)){
				transform.position.z += 10;
			
		}

		}
}

and then there are 2 objects with box colliders that are supposed to block the object from moving too far but it just isnt working.
The Collision isnt working by itself so I tried adding this script but it isnt working either.

function OnCollisionEnter(theCollision : Collision){
     if(theCollision.gameObject.name == "lWall"){
    	 transform.position.z += 10;
     }
     
     if(theCollision.gameObject.name == "rWall"){
      transform.position.z -= 10;
     }
    }

Any suggestions?

Moving the object by setting its transform.position (or using Translate) fools the collision system. You should move a rigidbody by adding forces or setting its velocity, but it would be easier to use a CharacterController instead. Unfortunately, the CharacterController has a capsule collider always aligned to the Y axis - you can’t change it to a box collider, nor tilt it, but can control its height and radius, and even transform it in a sphere. If a capsule or sphere works for you, the code could be as simple as this one:

var leftcontrol : GUITexture;
var rightcontrol : GUITexture;
private var controller : CharacterController;

function Start(){ // find the controls at Start, not Awake!
    leftcontrol = GameObject.Find("GUIleft").guiTexture;
    rightcontrol = GameObject.Find("GUIright").guiTexture;
    controller = GetComponent(CharacterController);
}

function Update () {
  for (var touch : Touch in Input.touches){
    if (touch.phase == TouchPhase.Stationary){
      if (leftcontrol.HitTest (touch.position)){
        controller.Move(Vector3(0, 0, -10));
      }
      else
      if (rightcontrol.HitTest (touch.position)){
        controller.Move(Vector3(0, 0, 10));
      }
    }
  }
}

NOTE: CharacterController and Rigidbody are mutually exclusive - delete the Rigidbody after adding the CharacterController.