There is no contact / collision code above, eg the code that calls EndGame().
Find where that is and use either layers and layermasks, or perhaps tags, or some unique way of identifying that something SHOULD restart versus something should NOT restart. You can also look for some tutorials on tags/layers/detecting collisions.
If you post a code snippet, ALWAYS USE CODE TAGS:
How to use code tags: Using code tags properly