rigidbody' is not a member of 'UnityEngine.Object ?

I'm geting the error:

Assets/_Scripts/LookAtTarget.js(38,16): BCE0019: 'rigidbody' is not a member of 'UnityEngine.Object'. 

and here's the code and that line 38 is near the bottom:

var LookAtTarget:Transform;
var damp = 6.0;
var bullitPrefab:Transform;
var savedTime=0;

function Update () 
{
    if(LookAtTarget)
    {
        var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
        transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp);

        var seconds : int = Time.time;
        var oddeven = (seconds % 2);

        if(oddeven)
        {
            Shoot(seconds);
        }
    }
}

function Shoot(seconds)
{
    if(seconds!=savedTime)
    {
        var bullit = Instantiate(bullitPrefab ,transform.Find("spawnPoint").transform.position , Quaternion.identity);
        bullit.rigidbody.AddForce(transform.forward * 1000);
        savedTime=seconds;
    }   
}

I'm not sure what I've done wrong here, spent a few hours on this one...

Thank you.

Instantiate() returns type Object, not type GameObject as your code assumes, and as you are not using strong typing on your variable declaration of bullit, it is being created as an Object type.

I haven't coded in UnityScript for a while, so I can't quite remember the correct casting method, but I'm pretty sure this is right.

var bullit : GameObject = Instantiate(bullitprefab, transform.Find("spawnPoint").position, Quaternion.identity);

This code should cast the Object returned by Instantiate() to a GameObject, which will allow your follow code to work properly.

You need to either do:

var bullit:GameObject= Instantiate(...);

or

var bullit = Instantiate(...) as GameObject;

Ok.. haha where does that go in these two lines?:

        var bullit : GameObject = (GameObject)Instantiate(bullitprefab, transform.Find("spawnPoint").transform.position, Quaternion.identity);

I tried using your two examples replacing var bullut : GameObject = but didn't know how to structure it properly and got more errors.

cheers.

You change source

var bullitPrefab:Transform;

var bullitPrefab:GameObject;

var bullit = Instantiate(bullitPrefab ,transform.Find("spawnPoint").transform.position , Quaternion.identity);

var bullit:GameObject = Instantiate(bullitPrefab ,transform.Find("spawnPoint").transform.position , Quaternion.identity) as GameObject;

and

re-seting bullitPrefab object in Main Camara