How to set var to the object a raycast touches first (updating)

I need to make a script where a variable is set to the object that a raycast is hitting first at any given moment. I usually post code, but this is one of the only scripting problems I have ever had no Idea what to do. My idea is somewhat like this

if(raytouch = computer){
      function("open computer interface");

I know this script is not javascript correct, but it gives an idea of what I want to do…
The problem I am having is setting the var to the gameobject, and then getting it to go into the code. It would also allow GUI that would show what you were looking at, displayed at the bottom of the screen.


Input.GetKeyDown() only returns true for a single frame, so you can either use Input.GetKey() or you can restructure your logic. It would look something like:

#pragma strict  

function Update() {
	if (Input.GetKeyDown(KeyCode.E)) {
	    var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
	    var hit : RaycastHit;
	    if (Physics.Raycast (ray, hit)) {
	        var go = hit.collider.gameObject;
	        var script = go.GetComponent(SomeScript);
	        if (script != null)