NullReferenceException using CompareTag

Can’t figure out what I’m doing wrong here but it keeps coming up with a NullReferenceException error on the CompareTag line. Maybe I’m using it incorrectly? Have tried everything.

function OnTriggerStay(other : Collider) {
	if (!other.transform.parent.CompareTag("Player")) {
		Debug.Log("something other than player");
	}
}

You’re trying to access the parent of a GameObject which does not have a parent. Check if it has a parent and then compare the tag. Try this:

function OnTriggerStay(other : Collider) 
{
    if (other.transform.parent && !other.transform.parent.CompareTag("Player")) {
       Debug.Log("something other than player");
    }
}

Does your GameObject with collider, got a parent with tag player? maybe try to put to your object the tag Player not at your parent, and then,
if (!other.CompareTag (“Player”)) {
Debug.Log(“something other than player”);
}

in your exemple, if an object, without parent stay in your trigger, it will cast an NullReferenceException. I think

I think that should be

if (other.transform.parent.CompareTag!=("Player")) {