Get GameObject From Another Script

I am trying to get a Gameobject from another script and assign it to a gameobject in the current script.

Here is the code I have so far:

piece1 = hit.transform.gameObject; //This sets my raycast object as piece1.
				piece1.GetComponent<ParticleHolder>();//This gets the script that has the object I want in it.
				piece = piece1.particle;//Particle is the name of the object I want to assign to piece.

Its your middle line of code that isn’t doing anything. I am going to assume that piece and particle are type Particle (since you didn’t specify). I would write the code like this:

piece1 = hit.transform.gameObject;
piece = piece1.GetComponent<ParticleHolder>().particle;

Of course, this assumes that particle is public in your ParticleHolder script.