Detecting for a variable from multiple potential scripts.

I have multiple objects, that deal damage with the colliders, although I get a lot of errors and null stuff.

Original code was simply:

	////Grab damage of collision
	damage = other.gameObject.GetComponent("Z95Projectile").damage;
        damage = other.gameObject.GetComponent("MediumExplosion").damage;
    		damage = other.gameObject.GetComponent("SmallExplosion").damage;

Failed attempted solution:

////Grab damage of collision
    	damage = other.gameObject.GetComponent("Z95Projectile").damage;
    	if (damage == null)
    	{
        damage = other.gameObject.GetComponent("MediumExplosion").damage;
        	if (damage == null)
    			{
        		damage = other.gameObject.GetComponent("SmallExplosion").damage;
    
    				if (damage  == null) {
    				//later
    				
    }	}	}	

This answer sort of helped, but not completely, because i am trying to use multiple different scripts, not players.

The issue there is that you are using GetComponent with a string. This results a reference of type Component. That component reference still needs to be cast down tot he type containing the variables.

I would recommend looking into interfaces. In your case, you would declare a IDamageable interface with a Damage property.

public interface IDamageable {
     int Damage { get ; set;}
}

Then all three scripts you are dealing with would implement the interface and you can use one line then.

IDamageable damageable = other.gameObject.GetComponent<IDamageable>();
if(damageable != null){
     int damage = damageable.Damage;
}