restricting clone number

im having a problem with this script sometimes making my gameobject clone to many times, how can i make it restrict to only cloning 1 time?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class destructible : MonoBehaviour {

public GameObject debrisPrefab;
public float strength;

void OnMouseDown() {
	DestroyMe ();
}

void OnCollisionEnter(Collision collision ) {

	if (collision.impactForceSum.magnitude > strength) {
		DestroyMe ();
	}

}
	void DestroyMe () {
		
		if (debrisPrefab) {
			
	Instantiate (debrisPrefab, transform.position, transform.rotation);
		}

	Destroy (gameObject);

}

}

Perhaps what is happening is that the OnCollisionEnter event is firing many times as it collides. This would trigger your DestroyMe script many times, which in turn might be making multiple instantiates.

Try adding a private bool isCloned at the beginning, and then;

void DestroyMe () {
         
         if (debrisPrefab && !isCloned) {
             
     Instantiate (debrisPrefab, transform.position, transform.rotation);
         }
    isCloned=true;
     Destroy (gameObject);
 }

This should ensure the Instantiate line can only run once.

im getting an error with the “isCloned”
public GameObject debrisPrefab;
public float strength;

void OnMouseDown() {
	DestroyMe ();
}

void OnCollisionEnter(Collision collision ) {

	if (collision.relativeVelocity.magnitude > strength) {
		DestroyMe ();
	}

}
	void DestroyMe () {
		
		if (debrisPrefab && !isCloned) {
			
	Instantiate (debrisPrefab, transform.position, transform.rotation);
		}
	isCloned = true;
	Destroy (gameObject);

	
}