Why the same line of code works in one place and not in another

So I have this code where I move a ball by either clicking or when a function is called. But it only works with the mouse button. When the function vuela() is started it instantiates a ball and SHOULD send it flying but it doesn’t… but if i click the mouse button then it works :frowning: Whats the problem. Thank you in advance.

CODE:

public GameObject pelota;

void Update()
{

	if (Input.GetButtonDown ("Fire2")) 
	{
		GetComponent<Rigidbody> ().AddForce (new Vector3 (500, 500, 0));
	}
}

	public void vuela()
	{	
	Instantiate (pelota, new Vector3 (5, 0, 0),Quaternion.identity);
	GetComponent<Rigidbody> ().AddForce (new Vector3 (500, 500, 0));

	}

}

Your not applying the force to the new instantiated game object just to the current one. Change the vuela method to

public void vuela()
{    
     GameObject go = Instantiate (pelota, new Vector3 (5, 0, 0),Quaternion.identity);
     go.GetComponent<Rigidbody> ().AddForce (new Vector3 (500, 500, 0));
}

This will first get the newly instantiated then apply the force to its rigid body.