acces functions from raycast

Hi im attempting to move an object when i hit it with a rayast but i have confused my self i can acces the script but i can figure out how i would check if it is open and closed already would i just make a bool so that when i hit the object if closed = true open it and visa versa

using UnityEngine;
using System.Collections;

public class openandcloseplayer : MonoBehaviour {


	
	void Update() 
	{
		if (Input.GetMouseButtonDown(0))
		{
			RaycastHit hit;
			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			if (Physics.Raycast(ray, out hit))
			{
				if (hit.collider.gameObject.tag == "Openable") 
				{
					var script = hit.collider.gameObject.GetComponent<OpenandClose>();

				}
			}
		}
	}

}


using UnityEngine;
using System.Collections;

public class OpenandClose : MonoBehaviour {
	public float openx;
	public float openy;
	public float openz;

	public float closex;
	public float closey;
	public float closez;
	




	void Open()
	{
		transform.position = new Vector3(openx, openy, openz);
	}

	void Close()
	{
		transform.position = new Vector3(closex, closey, closez);
	}
}

ive tried this but it cant seem to find the funtions

using UnityEngine;
using System.Collections;

public class openandcloseplayer : MonoBehaviour {

	bool openclose;
	
	void Update() 
	{
		if (Input.GetMouseButtonDown(0))
		{
			RaycastHit hit;
			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			if (Physics.Raycast(ray, out hit))
			{
				if (hit.collider.gameObject.tag == "Openable") 
				{
					var script = hit.collider.gameObject.GetComponent<OpenandClose>();
					openclose = !openclose;
					if (openclose == true)
					{
						script.Open();
					}
					else
					{
						script.Close();
					}

				}
			}
		}
	}

}