Controll over gameObject inside another objects class

My player is creating another gameObject called “bullet” on the same position as he is.
That “bullet” should track position of player and change it’s position.
Now I know how to do this in 2 scripts but I have no idea why this does not work.


public class player : MonoBehaviour {

public GameObject Bullet;
Vector3 startPosition,currentPosition;

// Use this for initialization
void Start () {
	startPosition = new Vector3 (gameObject.transform.position.x, gameObject.transform.position.y, 0);
	Instantiate (Bullet, startPosition, Quaternion.identity);

}

// Update is called once per frame
void Update () {

	currentPosition = new Vector3 (gameObject.transform.position.x, gameObject.transform.position.y, 0);
	Bullet.transform.position = currentPosition;

}

Tnx in advance.

Whenever you have problems with a method when programming, you should first take a look at the documentation.

Quote

Instantiate(original, position, rotation); Clones the object original and returns the clone.