Can I use deltaTime in OnCollisionEnter?

I want to destroy gameobject after 5seconds colliding with another object with “Player” tag.
Here is my script.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class insprac : MonoBehaviour {

public GameObject barprefab;
GameObject barclone;
public Text timetext;

private float time = 0;
private float delay = 5;
private bool count = true;

void Start () {
	
}

void Update() {
	time = time + Time.deltaTime;
	timetext.text = time.ToString ();
	Cloning ();
}

void Cloning(){
	if (count == true) {
		if (time > 5) {
			barclone = Instantiate (barprefab, transform.position, Quaternion.identity) as GameObject;
			count = !count;
		}
	}
}

void OnCollisionEnter(Collision col){
	if (col.gameObject.CompareTag ("Player")) {
		delay = delay - Time.deltaTime;
		if (delay <= 0) {
			Destroy (gameObject);
			time = 0;
		}
	}
}

}

Object didn’t be destroyed, and UI text doesn’t return to 0.

OnCollisionEnter is called only once. You could start a coroutine like this

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;

public class insprac : MonoBehaviour {

 public GameObject barprefab;
 GameObject barclone;
 public Text timetext;
 private float time = 0;
 private float delay = 5;
 private bool count = true;
 void Start () {
     
 }
 void Update() {
     time = time + Time.deltaTime;
     timetext.text = time.ToString ();
     Cloning ();
 }
 void Cloning(){
     if (count == true) {
         if (time > 5) {
             barclone = Instantiate (barprefab, transform.position, Quaternion.identity) as GameObject;
             count = !count;
         }
     }
 }
 void OnCollisionEnter(Collision col){
     if (col.gameObject.CompareTag ("Player")) {
             StartCoroutine(waitToDestroy());



     }
 }
private IEnumerator waitToDestroy()
    {
            yield return new WaitForSeconds(5.0f);
             Destroy (gameObject);
        
    }
}

just modify your code like this:

void OnCollisionEnter(Collision col){
     if (col.gameObject.CompareTag ("Player")) {
         Invoke("DestroyMethod",5f);
     }

void DestroyMethod()
{
 Destroy (gameObject);
}