Need help with projectiles destroying instantly

The projectiles have rigidbodies just like the players. The script I have shoots them from the middle of players rigidbody, and is what I wanted. But the problem is with destroying the projectiles. The script I’ve written destroys game objects on collision with colliders, but since it’s spawning in the middle of a game object it gets destroyed instantly. How can I avoid this?

Put some logic in the collider code. Use layers to prevent the two from interaction. Many ways