turret shoot if in range

so i`m making a game were turrets have to shoot at you though they should shoot only of the they are in range but when i save the code it gives me 2 errors:

Operator ‘<’ cannot be used with a left hand side of type ‘System.Type’ and a right hand side of type ‘int’

Cannot convert ‘float’ to ‘System.Type’,

here is the code i used:

    #pragma strict

function Start () {

}
var speed = 3000;

var distance = int;
var maxDistance = 50;
var myTransform = transform;

var LookAtTarget:Transform;

var bullitPrefab:Transform;

var damp = 6.0;

var savedTime = 0;

function Update () 
{
    distance = (LookAtTarget.position - myTransform.position).magnitude;


    if(LookAtTarget && distance < maxDistance)
    {
    var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);

    transform.rotation = Quaternion.Slerp(transform.rotation,rotate,Time.deltaTime * damp);

    var seconds : int = Time.time;

    var evenodd = (seconds / 2);

    if (evenodd) 
    {
    Shoot(seconds);
    }
    }
}   
function Shoot(seconds)
{

    if(seconds!=savedTime)
    {
       var bullit = Instantiate(bullitPrefab,transform.Find("spawnPoint").transform.position,
                    Quaternion.identity);

       bullit.rigidbody.AddForce(transform.forward * speed);

       savedTime = (seconds);    

    } 
}

so i hope someone can help me and thank you.

Your definition of distance is incorrect:

 var distance : int;

You have an “=” in there which makes distance a variable containing the type of an int :slight_smile: