Damage Script Question

So I got this little script that’s supposed to apply some damage to an object.

var health = 100;    
var hitPoints = 100;
var maximumHitPoints = 100.0;    
private var gotHitTimer = -1.0;    
var propWreck : GameObject;    
var impactDamage = false;    
var damage = 100;   
   
function OnCollisionEnter(collision : Collision) {  
   
if (collision.relativeVelocity.magnitude > 1 && collision.gameObject.tag=="frontalCollider")
  
	impactDamage = true;   
			if(impactDamage)   			
		 	hitPoints -= damage; 
			if (hitPoints <= 10) {
			WreckIt(); 
			}

}	   
function WreckIt () {
    	   
       Destroy(gameObject);
       Instantiate(propWreck, transform.position, transform.rotation);
}

What I am trying to do is control what damages the object using tags and collision.magnitude - just to be sure sometimes I have to hit the object harder to break it down not simply touch it. While at impact with any object - regardless it’s tag works well, I can’t seem to make the tag filtering work. pls help tx :slight_smile:

Well the way you check the tag is correct so you should check if your objects really have that tag. The easiest way is to print the tag / name of the colliding object:

function OnCollisionEnter(collision : Collision)
{
    Debug.Log("Collided with: " + collision.gameObject.tag);
    // [...]

Everytime you collide with something you should get a message in the debug-console. Now you should be able to figure out what’s the object you really collided with.