Object reference not set to an instance of an object issue

For some odd reason, my If statement in the Paddle class keeps giving me an error. The error says “NullReferenceException: Object reference not set to an instance of an object”. I cant wrap my head around this problem. I need to get the Boolean value of “isBlue” from the Ball Class into the Paddle class. Once it is in the Paddle class, I need to use that boolean value to transform a texture. Any Help would be greatly Appreciated. Thanks


Paddle class

#pragma strict

var blue: Texture;

var isBlue: boolean = false; 
Public var newBall : Ball;

function Start () {


function Update () {

newBall = GetComponent(Ball);
isBlue = newBall.isBlue;

if(isBlue == true){

renderer.material.mainTexture = blue;


Ball Class

var blue : Texture;

 var isBlue : boolean = false;


function OnCollisionEnter(col : Collision){

if(col.collider.name == "Brick3"){
renderer.material.mainTexture = blue;
isBlue = true;


This line will fail if the GetComponent(Ball) call fails to find the ‘Ball’ component. Note this call is expecting that the ‘Ball’ script will be on the same game object as the script above. If it is on another game object (like I would expect since this is the Paddle script), then you need to first get access to that other game object and then use that game object in the GetComponent() call:

 newBall = GameObject.Find("Ball").GetComponent(Ball);

Where the ball object has the name ‘Ball’. Note it would be more efficient to put the GetComponent() call in Start() and only call it once if there is only one ball during the life of the game.