Too Close To The Trap and melee attacking enemys.

I created an enemy that attacks when i get close to him. When I get close, it should coming out a bit from the water and attack me. The problem it that it don't works untill I get too much close to him, I meen that insted of it will start to attack me from 10 meters range, it attacks me from 1 meter range or less. I tried with 500 meters and it still doesn't works. How do I solve the problem?

Here is my script if something wrong there:

var distance;
 var target : Transform;
 var speed = 4.0;
 var landDistance;
 var land : Transform;
 var attackRange = 10.0;
 var floteRange = 2.0;
 var goUp = false;
 static var FIRE = false;

 function Update ()
 {
     distance = Vector3.Distance(target.position, transform.position);
     landDistance = Vector3.Distance(land.position, transform.position);

     if (distance < attackRange)
     {
         goUp = true;
     }
     else
     {
         FIRE = false;
     }

     if (goUp)
     {
         if (landDistance <= floteRange)
         {
             transform.Translate(Vector3.up * speed * Time.deltaTime);
         }
         else
         {
             FIRE = true;
         }
     }
 }

One more thing that i want to know is to create melee attack enemy. I don't know how to start, from where or anything else... Someone can tell me how to begin or the basics? It not something importent, it just can be fun to do...

Sorry for poor english...

Your code looks fine.

Make sure that you are changing the value of attackRange in the inspector and not in the script. For some reason I have found that once the script is attached to the object - changing the values in the script do not change the values for the object. You need to change them in the object inspector itself.