destroy bullets script!

Im making a shooting game and i really need to add to my script to make the bullets disappear in 2 seconds

var bullet : Transform; //Your bullet prefab.
var speed : float = 10.0f;
var muzzlePoint : Transform; //Your SpawnPoint

function Update() {
    if(Input.GetButtonDown("Fire1")) {
        var instance : Transform = Instantiate(bullet, muzzlePoint.position, 
        instance.velocity = muzzlePoint.forward * speed;

could anyone please edit this script for me! thanks!

There are more efficient ways of doing this (like monitoring the number of existing bullets in the scene and culling them when over a thresh hold). But for what you’re asking you would want to use a coroutine. You may need to gate it with a bool in the update method. This is in C# since my JS is junk

IEnumerator cleanBullets () {
isReady = false;
//Destroy bullet code here
yield return new WaitForSeconds(2f);
isReady = true;

then in update you would want something like

if (isReady) StartCoRoutine(cleanBullets());