You may be having collisions with the ground or other objects that don’t have the script BaseStats. The easiest way to avoid this is to check if the object hit has a BaseStats script:
function OnCollisionEnter(collision:Collision)
{
var baseStScript: BaseStats = collision.gameObject.GetComponent(BaseStats);
if (baseStScript){
var optype1 = baseStScript.type1;
var optype2 = baseStScript.type2;
...
}
}