[JS] Null Reference Exceptions for no reason

Ok,

I am getting the null reference exception for a loop in my OnDrawGizmos() function.

function OnDrawGizmos()
{
	for(var i = 0; i < collisionPositions.Length; i++)
	{
	Gizmos.color = Color.cyan;
	Gizmos.DrawSphere(collisionPositions[i], 0.01);
	}
}

These errors are coming up while in edit AND game mode. This has never happened to me before – help?

Which part of the code is giving you an error?

It must be line 3, meaning the collisionPositions array is null.

function OnDrawGizmos()
{
    if (collisionPositions != null) {
        for(var i = 0; i < collisionPositions.Length; i++)
        {
            Gizmos.color = Color.cyan;
            Gizmos.DrawSphere(collisionPositions[i], 0.01);
        }
    }
}