i need to mix this scripts, gun shoot

I want to mix scripts:

var prefabBullet:Transform;
var shootForce:float;
var shots : int = 0;
var maxShots : int = 8;
var shootSound : AudioClip;
function Update()
if(Input.GetButtonDown("Fire1") && shots < maxShots)
var instanceBullet = Instantiate(prefabBullet, transform.position, Quaternion.identity);
instanceBullet.rigidbody.AddForce(transform.forwar d * shootForce);
else if (shots >= maxShots && Input.GetKeyDown(KeyCode.R))
shots = 0;

I like this because you have limit bullets , but with this script i cant delete the bullets(clone) but with this script i can:

var projectile : Rigidbody;
var speed = 20;

function Update () {

if ( Input.GetButton ("Fire1")) {

clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection( Vector3 (0, 0, speed));

Destroy (clone.gameObject, 3);


And i need that the bullet make a hole

This is easy: just call Destroy in the first script, right after creating the bullet:

  instanceBullet.rigidbody.AddForce(transform.forward * shootForce);
  Destroy(instanceBullet.gameObject, 3);

About the bullet hole: you must create it when the bullet collides with something. Add a script like this to the bullet prefab:

var holePrefab: GameObject; // drag the hole prefab here

function OnCollisionEnter(col: Collision){
  Destroy(gameObject); // destroy the bullet
  var contact: ContactPoint = col.contacts[0]; // get the first hit point
  // calculate the hole position in front of the hit point:
  var pos: Vector3 = contact.point + contact.normal * 0.005;
  // find a rotation that aligns the plane with the surface:
  var rot: Quaternion = Quaternion.FromToRotation(Vector3.up, contact.normal);
  // instantiate the hole:
  var hole: GameObject  =  Instantiate(holePrefab, pos, rot);
  // "glue" the hole to the object hit by childing it: 
  hole.transform.parent = col.transform;
  Destroy(hole, 30); // destroy the hole automatically after 30 seconds

The hole prefab itself is a small plane with an appropriate material. Use the Unity’s Quad primitive to create a simple plane, set its size and assign to it a material with the Transparent/Cutout/Diffuse shader and the hole texture.