MousePosition Raycast hits everything on screen?

so i have 4 different game objects on the screen each with their own script (example below with respective changes in each to identify them) but when i start my project and click on one of them all of them are hit by the Raycast is that what is supposed to happen? as ideally i would like to identify all 4 separately

	void Start () {	}
	

	void Update () {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.transform.gameObject)
                {
                    PlayerPrefs.SetFloat("obj", 2);
                    Debug.Log("This is object2");
                }
                else
                {
                    Debug.Log("No object");
                }
            }

        }
    }
}

Well, the only thing you’re checking for is if any object is hit. It should be more along the lines of

if (hit.gameObject == gameObject)

rather than

if (hit.transform.gameObject)