[Help] NPC Spawn with Respawn and with Team

I have the NPClife script for spawning NPCs. The only problem is that it’s not working goodly. The only problem is that if a new player joins that it will be + 1 NPC and they won’t respawn. Could somebody fix it? It would be the best to have a script for spawning and respawning NPCs after they died.