Multiple GameObjects with the same script all react but I only want one at a time.

Okay so I had a pickup script on my player which picked up stuff via raycast but that was buggy as hell for some reason so i made a script on the actual gameobject but when I click an object all objects with the script gets picked up. Now its pretty obvious why, I mean they just all change their position but anyway i wanted to know if there was some way of fixing it without making the same script thrice with a different name…

Heres the script (its not exactly mine by the way. i dont wanna take any credit i just modified it):
using UnityEngine;
using System.Collections;

public class PickUpObject : MonoBehaviour {
	public Transform player;
	public GameObject playerObject;
	public float throwForce = 10;
	bool hasPlayer = false;
	bool beingCarried = false;
	
	void OnTriggerEnter(Collider other)
	{
		hasPlayer = true;
	}
	
	void OnTriggerExit(Collider other)
	{
		hasPlayer = false;
	}	
	
	void Update()
	{
		if(beingCarried){
			transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (Screen.width / 2, Screen.height / 2 + 200, 2));
			transform.LookAt(playerObject.transform.position);
			//transform.LookAt(new Vector3(player.position.x, transform.position.y, player.position.z));
			transform.Rotate(new Vector3(0, 270, 200));

			if(Input.GetMouseButtonDown(0)){
				rigidbody.isKinematic = false;
				transform.parent = null;
				beingCarried = false;
				rigidbody.AddForce(player.forward * throwForce);
			}
		}
		else
		{
			if(Input.GetMouseButtonDown(0) && hasPlayer){
				rigidbody.isKinematic = true;
				transform.parent = player;
				beingCarried = true;

			}
		}
	}
}

Hey everyone im sorry for being so terrible at explaining what i wanted but i fixed so heres my script. Thank you very much for you help. `using UnityEngine;
using System.Collections;

public class NewPickUp : MonoBehaviour {

public GameObject item;
public GameObject item2;
public GameObject pickUpText;
private float customHeight = 0;
public float throwForce = 10;
public bool beingCarried = false;

void Update () {
	Ray ray = camera.ScreenPointToRay(new Vector3 (Screen.width / 2, Screen.height / 2, 2));
	Debug.DrawRay(ray.origin, ray.direction * 1.7f, Color.yellow);
	
	RaycastHit hit;
	
	if (Physics.Raycast (ray, out hit, 1.7f)) {
		if(hit.collider.name == "item"){
			pickUpText.guiText.enabled = true;
			if(beingCarried){
				pickUpText.guiText.enabled = false;
				item.transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (Screen.width / 2, Screen.height / 2+customHeight, 2));
				item.transform.LookAt(transform.position);
				
				if(Input.GetMouseButtonDown(0)){
					item.collider.isTrigger = false;
					item.rigidbody.isKinematic = false;
					item.transform.parent = null;
					beingCarried = false;
					item.rigidbody.AddForce(transform.position*throwForce);
				}
			}
			else
			{
				if(Input.GetMouseButtonDown(0)){
					item.collider.isTrigger = true;
					item.rigidbody.isKinematic = true;
					item.transform.parent = transform;
					beingCarried = true;
				}
			}
		}
		else
		{
			if(hit.collider.name == "item2"){
				pickUpText.guiText.enabled = true;
				if(beingCarried){
					pickUpText.guiText.enabled = false;
					item2.transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (Screen.width / 2, Screen.height / 2+customHeight, 2));
					item2.transform.LookAt(transform.position);
					
					if(Input.GetMouseButtonDown(0)){
						item2.collider.isTrigger = false;
						item2.rigidbody.isKinematic = false;
						item2.transform.parent = null;
						beingCarried = false;
						item2.rigidbody.AddForce(transform.position*throwForce);
					}
				}
				else
				{
					if(Input.GetMouseButtonDown(0)){
						item2.collider.isTrigger = true;
						item2.rigidbody.isKinematic = true;
						item2.transform.parent = transform;
						beingCarried = true;
					}
				}
			}
			else
			{
				if(hit.collider.name == "item3"){
					pickUpText.guiText.enabled = true;
					if(beingCarried){
						pickUpText.guiText.enabled = false;
						item3.transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (Screen.width / 2, Screen.height / 2+customHeight, 2));
						item3.transform.LookAt(transform.position);
						
						if(Input.GetMouseButtonDown(0)){
							item3.collider.isTrigger = false;
							item3.rigidbody.isKinematic = false;
							item3.transform.parent = null;
							beingCarried = false;
							item3.rigidbody.AddForce(transform.position*throwForce);
						}
					}
					else
					{
						if(Input.GetMouseButtonDown(0)){
							item3.collider.isTrigger = true;
							item3.rigidbody.isKinematic = true;
							item3.transform.parent = transform;
							beingCarried = true;
						}
					}
				}
			}
		}
	}
	else
	{
		if(!Physics.Raycast(ray, out hit, 1.7f)){
			pickUpText.guiText.enabled = false;
		}
	}
}

}`

Yeah it might now be the most optimized script but it works so you know. Thanks again for your help.

Take a look at the this keyword. It acts only upon the instance of its class, instead of on every class instance.

private bool increment = false;
private int incremented = 0;

void Update()
{
	if(Input.GetKeyDown("X")) {
		this.increment = true;
	}
	
	if(this.increment) {
		this.incremented++;
		this.increment = false;
	}
}

void OnGUI()
{
	GUI.Label(new Rect(20,20,400,20), this.incremented.toString());
}