Touch goes through UI button

The problem is that when I tap my pause button, and then click resume, two balls will spawn. I added a line of code but it doesn’t seem to be working:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class BallSpawn : MonoBehaviour {

public GameObject Ball;
public Touch _touch;

void Update () {
	var pointerOverObject = UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject();  
	if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began && !pointerOverObject){
		Instantiate (Ball, transform.position, Quaternion.identity);
		GameObject.Find ("Dropper first frame").GetComponent<Animator> ().Play ("DropperAnimation");
	}

		

}

}

I forgot to say this but I only want the balls to spawn when i click anywhere on the screen but the Button