GetComponent

i have a problem with unity and i thing the new unity API is shit because of it

 var projectile : Transform;
 var speed = 1;
 var barrel : Transform;
 var shots :  int  =  0 ;
 var maxShots :  int  =  1 ;
 
 function Update () {
 
 if ( Input.GetButtonDown ("Fire1") && shots < maxShots){
 
 clone = Instantiate(projectile, barrel.position, barrel.rotation);
 
clone.GetComponent<Rigidbody>().velocity = barrel.TransformDirection(Vector3 (0, 0, speed)); 
 shots ++;
 
 }
 else if (shots >= maxShots && Input.GetKeyDown(KeyCode.R))
     {
 yield WaitForSeconds(0.5); 
         shots = 0;
     }
 }

maybe im wrong but that script is fine, i did exactly what the scripting reference said but i always get these errors:

Assets/MY Assets/Scripts/StoneFire.js(13,31): BCE0043: Unexpected token: ).

Assets/MY Assets/Scripts/StoneFire.js(13,32): BCE0044: expecting ), found ‘.’.

Assets/MY Assets/Scripts/StoneFire.js(13,33): UCE0001: ‘;’ expected. Insert a semicolon at the end.

can someone please tell me what im doing wrong because i dont get.
every time i change the things to what the errors say there will just appear errors about the fixed errors saying i should go back to the old thing (script showed above).

thanks i wou,d really appriciate your help

Unity’s new API is shit? lol? Do you even know what you’re saying?

The error is saying that something is wrong with this line right here:

clone.GetComponent().velocity = barrel.TransformDirection(Vector3 (0, 0, speed)); 

Look at the API:

Remember to click JS on the top right corner in the API pages, not C# because that’s the mistake you made.

Use

clone.GetComponent(Rigidbody)