How do I access another gameobjects components?

Heres what I’m trying to do but failing miserably at.

I have a Trigger (box collider) that loads a new scene.

What I would Like is for it to change an int on my players script before it loads the new level.

Here is the script I have on my player

#pragma strict

function Start () {

public var PreviousLevel
PreviousLevel : int;

}

Here is the code for my level trigger

function OnTriggerEnter ()
{
	GameObject.FindGameObjectWithTag("Player");
	GetComponent("PreviousLevel")
	PreviousLevel = 0;
	
Application.LoadLevel("Cave of Discovery");
}

Obviously this script isn’t working… Im sure there is some way of calling on another gameobjects scripts and altering that scripts variables… I just have no clue how… I figured this is a goodd method of keeping track of previously visited scenes, so when a new level is loaded… The system knows where to place my character… This is a rpg… so an example would be… walking to a door… the door loads the interior of the house (new scene)… If you came in from this door… spawn here ect ect ect… please help me get this working. Thanks Much - Josh

Trigger functions require overloads

function OnTriggerEnter (other:Collider)
{
    if(other.CompareTag("Player"))
    {
        var pl=other.GetComponent(PreviousLevel);
        pl.previousLevel = 0;

        Application.LoadLevel("Cave of Discovery");
    }
}

You need to make sure that the PreviousLevel script has the DontDestroyOnLoad attribute, other wise your changes will not matter.

This script on your player needs to have the variable declarations outside of the function in Javascript.

#pragma strict

public var previousLevel:int; //This is set to 0 by default

function Start () {

}