How to only click on certain objects/buttons and null the rest please help!!

Hey everyone, I was wondering if anyone could help me with this. I have been trying to figure it out for days. I would really appreciate the help. I am trying to figure out how to null/not have click activated when I click on the pop up UIs. The pictures as shown:


I have a script in which I am able to click on the triangles. The blue space is nulled out/does not do anything. The code I am using is:

public class ClickObject : MonoBehaviour {
private GameObject NextLevelUI;
private GameObject TryAgainUI;

	void  Update (){

		RaycastHit2D hit;


			hit=Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition) ,;
			if (hit.collider != null){
				if(hit.collider.GetComponent<MoveSample>()!= null && hit.transform.gameObject.tag=="TriangleP"){
					TryAgainUI.SetActive (false);{

When I click on the right object that has the movesample script attached, It directs to the correct pop up UI. When I clicked on the wrong object, it goes to the incorrect pop up. Here is an example of the correct UI:


What I want to do is have the ability to ONLY click on the button and nothing else. The triangles and background all null/unable to do anything. I have been looking into bools, event systems, if else statements, but not sure how to do this. If anyone could help I would GREATLY appreciate it. Thank you.

Create layers for the objects you want your raycasts to hit and when you perform your:

hit=Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition) ,;

use instead:

You can find info on using Layer tags here - Tags and Layers