I have this script reading a static var from another script and it works just fine when target is selected. The code below is attached to a homing missile.
Variables should be in camelCase while functions are in CamelCase.
You can’t access members of null (since it isn’t)
You’re trying to access null.transform which is impossible.
Use
if ( targetEnemy.target ) target = targetEnemy.target.transform;
Edit @JM: You can’t use targetEnemy before it’s given meaningful information. At the start of the function in this particular case it can only contain ‘garbage’ data.