Scripting woes, door will not open

How can I get this to work, every time I plug in the designated script for the door to open that is detailed in the unity essentials book it then has supposed "unknown identifiers- doorIsOpen etc" galore even though the people using it have all said the contrary that it supposedly always works...

function OnControllerColliderHit (hit : ControllerColliderHit) 
    if (hit.gameObject.tag == "outpostDoor" && doorIsOpen == false) 
        currentDoor = hit.gameObject; 
        Door(doorOpenSound, true, "dooropen", currentDoor); 

    var hit : RaycastHit;

    if(Physics.Raycast(transform.position, transform.forward, hit, 5)) 
        if(hit.collider.gameObject.tag == "outpostDoor" && doorIsOpen == false)
            currentDoor = hit.collider.gameObject;
            Door(doorOpenSound, true, "dooropen", currentDoor);

Please help.

Check where it is you declared the variable doorIsOpen. If it is inside of a function, then that means it'll only be known inside of that function. Your OnControllerColliderHit function can't find it because some other function is stealing all of doorIsOpen's attention.

Don't declare it inside of a function if you want more than one function to talk to it.

I won't be bothered reading the whole article, but I can provide my own implementation for opening/closing doors.

First is the script for the door. It is quite minimal. OnInteract is what the door will do when a user interacts with it. Here you might want to add more features such as playing a sound with audio.Play() for example. You can make all sorts of scripts that have OnInteract, with this approach. Maybe you want to make a button? Maybe you want to make a car you can enter. All of this can make use of this basic skeleton.

// Door.js
var isOpen : boolean;

function OnInteract()
    var anim = isOpen ? "CloseDoor" : "OpenDoor";
    isOpen = !isOpen;

Then is the script for the player, that interact with the door. I chose to query the main camera to avoid restrictions that you must put it on a camera and for ease of use. range variable is how far the player can reach. blockingLayers are which objects block a raytest. This can be useful if you have certain triggers that would block the ray.

// Interacter.js
var range : float = 5;
var blockingLayers : LayerMask = -1;

function Update()
    if (Input.GetKeyDown(KeyCode.E))

function Interact()
    var hit : RaycastHit;
    var ray : Ray = Camera.main.ViewportPointToRay(Vector3(0.5, 0.5, 0));
    var options = SendMessageOptions.DontRequireReceiver;

    if (Physics.Raycast(ray, hit, range, blockingLayers))
        hit.collider.SendMessage("OnInteract", options);

It is quite minimalistic and I hope you have a better chance learning scripting this way. Free code is frowned upon, but I also realize when you are struggling the most and want to come to a quick resolution to keep the spirits high. I provide this code free to you this time, but don't expect to always be lucky! :)

No, you misunderstood, I have tired that and every other possible valid series of scripts for this I could find on this site and it still doesn't work and the book clearly states that you are suppose to set these functions inside /* then supposedly it will work..

Could you or anyone bestow to me a formatted script that will work. I tried both methods in this book and neither work for me.

Fyi the ones found here :