Changing bool of raycasthit.parent

Hello there!

I’m looking to change the bool of a raycasthit’s parent.

Current Script:

static var dTog : boolean;
var hit : RaycastHit;

function Update()
{
	Debug.DrawRay (transform.position, transform.forward, Color.red);
	if(Physics.Raycast(transform.position, transform.forward, hit, 100.0))
	{
		
		if(hit.collider.CompareTag("button"))
        {
	        if(Input.GetKeyDown(KeyCode.E))
	        {
	        	hit.transform.parent.thisD = !hit.transform.parent.thisD;
	        	print("door is open/close");
		}
        }
	}
}

Currently this gives me nothing but a “Enumerable 1 Error”.

Is there anything you guys can see wrong in it? :slight_smile:

I would appretiate the help greatly!
Sincerely,

Bakos133

hit.transform.parent is of type Tranform.

You will need to call GetComponent() if you want to access an attached script.