When I copy an object with a script, it doesn't work correctly, how do I fix this?

I have a player and a zombie, I made a script that knocks back the player when the zombie and player get too close to each other, this works fine with one zombie, but when I copy the zombie, everything works, except the copied zombie doesn’t knock the player back, but the original does. I found a solution where if I copy the player, delete it, then paste it after duplicating the zombies, all the zombies will knock the player back, however, I don’t want to delete and paste the player every time a new zombie is added.

People can’t really answer specifics about your question without the related code.

But, if I had to make a wild guess, maybe your player has a script to search for all zombies when your player spawns. So, if you make a new zombie, the player does not see that because the zombie did not exist when the player spawned. And when you make a new zombie and then recreate the player, the player does the search on spawn and sees all the existing zombies.