Basic beginning javascript question. (logging position and moving character to logged position)

Hi..this is one of my first forays into javascript (nearly all of my experience is in c++), and I've hit a snag that I cant quite find on my own...this is a (very) simple script meant to log the player's position every 5 seconds and to relocate the player to the logged position if they enter water. It is executing correctly except that the position is not being logged; only the initial position is being used.

Also, when the code is compiled inside unity, the variable waterLevel does not show up as being alterable without actually opening the script and changing the code directly. Is there a trick to making it do so?

I apologize for asking such a basic question on here, but I'm not sure what exactly the problem is...It compiles fine, but the behavior I think I wrote just isnt happening.

UPDATE: Although I could not get the 5-second interval to work correctly, I did manage to get it to log the position every time the script is run as long as the controller is 15 units above the set sea level.

Thanks for the answers; I appreciate them.

Have a nice day.

private var pos : Vector3;
var waterLevel :int = 90;

function Start () {

 pos=transform.position;
 counter=0;

}

function Update () {

` if (transform.position.y<waterLevel)
{
transform.position=pos;
counter=0;

        }

    if (transform.position.y>waterLevel+15)
        {
        pos=transform.position;     
        }

`

}


edited to correct sloppy code

edited to reflect new code accomplishing task(though not the intended way)

There are several problems here...the variables aren't typed as anything (except for "waterLevel"), which is probably the main issue, the code you posted isn't valid (copy & paste error?), "1*Time.deltaTime" is redundant, instead of using 3 separate variables for the position use a single Vector3, and it would be simpler to use InvokeRepeating instead of Update.

Did you drag and drop this into a scene GameObject? The global variables should be exposed in the inspector of that object, once you do so.