Check Trigger Collision's Name/Tag

I’m making hitboxes for my game and as a simple test I want them to turn yellow whenever on hitbox touches another.

To start off, I created an onTriggerEnter function

function OnTriggerEnter(collision : Collider){
	gameObject.renderer.material.color = Color.yellow;
}

This works perfectly fine. If a hitBox touches a trigger, it turns yellow. But when I add an if statement that refers to the collision’s game object, it doesn’t work.

function OnTriggerEnter(collision : Collider){
	 if(collision.gameObject.name == "hitBox"){
		gameObject.renderer.material.color = Color.yellow;
	}
}

I’ve tried different variations with “name”, “tag”, with and without “gameObject”, but nothing happens. Is there something that I’m missing? Am I referencing the wrong thing? Any help is appreciated.

Thank you for your help, everyone! What solved my problem was adding a kinematic Rigidbody to my hit boxes. I realized that the reason why it had worked without the tag check was because they were touching other objects that happened to have their own Rigidbodies. I’m surprised I didn’t even consider this. Now by adding Rigidbodies to the hit boxes, their collisions are finally registering. Thank you again!