It looks like your getting the null exception as you are attempting to get the script from the actual PickUpBall class itself. Below I have posted some code I whipped up that may serve you better and some comments on why. I also linked this to my file on my github for a nicer reading format.
As I state in the comments, I removed the instantiate from the fixed update as this means you are instantiating 60 game objects a second, assuming you are running at 60 FPS. A better choice would be using enable and disable, and moving the GameObject. As I'm not completely sure of the functionality, I can't completely fix this as I'm not sure what the needs are, but I assume making 60 objects a second is unneeded no matter what.
If you have any questions, or anyone has anything they want to me to update on the script, leave a comment or a pm.
using System.Collections;
using UnityEngine;
public class ThrowBall : MonoBehaviour {
public float increaseRate;
public GameObject AimAssist;
private PickUpBallScript pickUpBallScript;
private bool holding;
private float strength;
private RigidBody aaRb;
private GameObject createdAimAssist; //A created object from the AimAssist prefab
void Start() {
//I am assuming this script is attached to this game object
//if not you need to have a refrence to the game object
//that PickUpBall is actually on
pickUpBallScript = GetComponent<PickUpBall>();
//Instantiated here so as to help performance
createdAimAssist = Instantiate(AimAssist);
//The Rigidbody was referencing a prefabs rigid body
//it should instead refrenece the created game objects
//RigidBody
aaRb = createdAimAssist.GetComponent<RigidBody>();
}
void FixedUpdate() {
//Can just use the straight reference to the script rather
//then update a bool every frame
//Also switched to Fire1 in case user is using a controller
if (pickUpBallScript.holding && Input.GetKey("Fire1")) {
strength += increaseRate;
aaRb.AddForce(strength, 0, 0);
//Removed the instantiate as that is quite heavy on the
//engine and will quickly cause performance issues
}
}
}
https://github.com/Gizmmo/RedditUnity3D/blob/master/332ajl/ThrowBall.cs