About shooting (JavaScript)

I’m new here, but I have an issue that wastes my time, so I decide to ask.
I expected to have these things to happen

  1. 1.It’s moving

  2. It shoots cube out when left clicking

  3. The cube(cloned one) is destroyed when it touches the ground

So, it can move, and can shoot.
but it deletes the cube itself and errors appear(Ya, that destroyed item and I try to access error)

I’m sorry. But I got no choice but to ask, both google and youtube can’t help me.

#pragma strict
var player : GameObject;
var forward : float;
var rotate_H : float;
var rotate_V : float;
var bullet : Rigidbody;
function Start () {}

function Update () {
 var move_forward = Input.GetAxis("Vertical") * 5;
GetComponent.<Rigidbody>().AddRelativeForce
(0, 0, move_forward * 10);

 rotate_H += Input.GetAxis("Mouse X") * 10;
 rotate_V -= Input.GetAxis("Mouse Y") * 10;
 if (rotate_V > 50) {rotate_V = 50;};
 if (rotate_V < -80) {rotate_V = -80;};
 transform.rotation = Quaternion.Euler(rotate_V, rotate_H, 0);
 
 if (Input.GetButtonDown("Fire1")) {
 var bullets : Rigidbody;
 bullets = Instantiate(bullet, transform.position, transform.rotation);};
 bullet.GetComponent.<Rigidbody>().AddRelativeForce(0, 0, 500);
 Destroy(bullets.gameObject,2);
}

function OnCollisionEnter (col : Collision) {
if (col.gameObject.name == "Cube") {Destroy(gameObject);}
}

Dude easy fix.
On line 23 you wrote:
bullet.GetComponent.().AddRelativeForce(0, 0, 500);
but your variable name is bullets, so change bullet to bullets.
Also if that doesn’t work try replacing the whole script with this simplified version:

var projectile : Rigidbody;
var speed = 30;

function Update () {
	if(Input.GetMouseButtonDown(0)){
	Shoot();
}

function Shoot () {
	var clone = Instantiate(projectile, transform.position, transform.rotation); 	
	clone.velocity = transform.TransformDirection(Vector3(0,0,speed));
}

and for the collision destroy script that you will add to the bullet prefab:

function OnCollisionEnter (col : Collision) {
	Destroy(gameObject);
}