how can i make a explosion when my player hit any gameodject

i want when my player hit a cube in my game make a explosion (i already have my explosion)
i just need the script part

You can make the cube a trigger and use OnTriggerEnter to fire the explosion, or you can let it be a collider and use OnControllerColliderHit (I’m supposing that your player is a CharacterController).

If the cube will explode and disappear, it’s easier to use the trigger - the code below must be attached to the cube script:

var explosion: GameObject;

function OnTriggerEnter(col: Collider){
    if (col.tag == "Player"){ // check if your player is tagged "Player"!
        var expl = Instantiate(explosion, transform.position, Quaternion.identity);
        Destroy(gameObject); // use this if you want to destroy the cube
        Destroy(expl, 4); // destroy the explosion after 4 seconds

Now, the bad news: if you want to throw the player back with the explosion, you’ll have to do that in the player script. If this is the case, post your current player script, so we can have an idea on how to add this feature.