How to add force to an existing object?

I’m trying to make a script that spawns a ball in front of you so that you can hold it and throw it. I can spawn the ball but I only know how to make it move directly after it spawns. I’m also having trouble getting the ball to stay in front of you, I’ve tried parenting the ball to the object I used to spawn it in the right position but it just gives me an error. Please help me!

This is what I have so far, all it does is spawn a ball that floats:

var Ball : Rigidbody;
var ballNumber : int;
private var fireEnabled : boolean = true;
var hold : boolean = false;

function Start()

{

ballNumber = 5;

}

function Update()

{

if(ballNumber > 0 && hold == false)

		{

		var ballSpawnPoint : GameObject = gameObject.FindWithTag("HoldPosition");

		var ballFire = Instantiate(Ball, ballSpawnPoint.transform.position, ballSpawnPoint.transform.rotation);
		
		Ball.rigidbody.useGravity = false;
		
		hold = true;
		
		if(Input.GetKeyDown("e")&& fireEnabled == true)
			{

			Ball.rigidbody.useGravity = true;
			rigidbody.findWithTag("pickup").AddForce(Vector3.forward * 2000);
			ballNumber -= 1;
			hold = false;
			fireEnabled = false;
			firePause();
		
			}
		
		}
}

function firePause()

{

yield WaitForSeconds(0.7);

fireEnabled = true;

}
  1. You do know that with useGravity off it will still move pretty much on its own if it collides with anything. Maybe use isKinematic instead?
  2. Pretty sure its GameObject.FindWithTag(“asd”) // To clarify: gameObject is the gameobject you have the script on. GameObject is the class. // You should consider not using tags to find objects like this. Tags are very limiting. I used to use them before, but they are close to useless to me now.
  3. To fix your linking problem. ( .parent ) is a function of the Transform class. Make Ball a GameObject. And use gameObject.transform.parent to use this function. And gameObject.rigidbody to access the rigidbody.