Joystick Raycast Problem?

Hi to all)) I use if(Physics.Raycast(ray, out hit, 4.0f)){ for placing or delete block on screen position touch. But even if i touch my Joystick or another button, raycast delete block when i touch my Joystick. I allready try to use LayerMask but with no succes How can i ignore my Joystick from RayCasting? Can any one help me with this?
Here the part of my code:

if (Input.GetMouseButtonDown(0)){ 
if(buttonTimer == 0){
if(hand.gameObject.active == true){	
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, 4.0f)){	
Vector3 hitPoint = hit.point + (ray.direction.normalized * 0.01f);
IntVect blockHitPoint = new IntVect((int)hitPoint.x, (int)hitPoint.z,    (int)hitPoint.y);
m_World.Dig(blockHitPoint, hitPoint);
}
buttonTimer = buttonCoolDown;
}
}

Please some one help me figure it out.
I search this forum, and find some answer, but it didnt help me(

I update code to use Touch Input, but problem is still.

  if (Input.touchCount == 1 ) {
    Touch touch = Input.touches[0];
    if(hand.gameObject.active == true){	
    if(touch.phase == TouchPhase.Began){
    if(buttonTimer == 0){
    Ray ray = Camera.main.ScreenPointToRay(touch.position);
    RaycastHit hit;
    if(Physics.Raycast(ray, out hit, 4.0f)){	
    Vector3 hitPoint = hit.point + (ray.direction.normalized * 0.01f);
    IntVect blockHitPoint = new IntVect((int)hitPoint.x, (int)hitPoint.z, (int)hitPoint.y);
    m_World.Dig(blockHitPoint, hitPoint);
    }	
    buttonTimer = buttonCoolDown;
    }
    }
    }
    }

I made it by miself)
Here Solution:

if (leftJoy.HitTest( Input.mousePosition )) {

					return;

				}

I made it by miself))
Here solution:
if (leftJoy.HitTest( Input.mousePosition )) {

					return;

				}