only one prefab doing all prefabs functionality

so i have three enemies in a scene that draw rays and if the player is hit by that ray they should shoot a bullet. the thing is only the first object to hit the player will shoot if two enemies hit the player the enemy that seen the player first will shoot two bullets. any help is greatly appreciated
Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TyphlosisOfFaith : MonoBehaviour
{
public int health;
public float speed, closeRange, attackRange, maxRange;
public Player player;
GameObject sphere;
[SerializeField] private GameObject bulletPrefab;
private GameObject bullet;
Transform bSpawn;
public Material coreBaseMat, coreDangerMat;
Transform core;
// Use this for initialization
private void Awake ()
{

    player = GameObject.Find("Player").GetComponent<Player>();
    health = 200;
    maxRange = 75;
    attackRange = 10;
    closeRange = 5;
    speed = 10;
    bSpawn = GameObject.Find("bulletSpawn").transform;
    
}

// Update is called once per frame
private void Update ()
{
    if (this.bullet != null)
    {
        this.bullet.transform.Translate(Vector3.forward * 50 * Time.deltaTime);
    }

    

    Vector3 target = new Vector3(player.transform.position.x, transform.position.y, player.transform.position.z);
    transform.LookAt(player.transform);
    Ray ray = new Ray(transform.position, transform.forward);
    RaycastHit hit;

    if (Physics.SphereCast(ray, 0.5f, out hit))
    {
        if (hit.transform.tag == "Player" )
        {
            
             bullet = Instantiate(GameObject.CreatePrimitive(PrimitiveType.Sphere), bSpawn.position, bSpawn.rotation);
            //bullet.transform.parent = transform;
            
            StartCoroutine(DestroyOnTime(.5f));
            //bullet.transform.parent = null;
        }
    }

    if (Vector3.Distance(transform.position, player.transform.position) < attackRange && Vector3.Distance(transform.position, player.transform.position) > closeRange)
    {
       // transform.Translate(transform.forward * Time.deltaTime * speed);
    }

    else if(Vector3.Distance(transform.position, player.transform.position) < closeRange)
    {
        core = transform.GetChild(1);
        core.GetComponent<Renderer>().material = coreDangerMat;
    }
   
}

IEnumerator DestroyOnTime(float time)
{
    yield return new WaitForSecondsRealtime(time);
    Destroy(this.bullet);
}

}
i have tried creating a script that places all objects in the scene rather than using the gui, still does it. is it something to do with the fact all the prefabs are operating with the same raycast and if so how do i stop it. read something a week or so back that was talking about making a variable static all instances of that prefab will share the value variable but no var is static? also does static not mean that only one instance of the object can be created. also the script is a bit messy because i was trying to fix the problem.

Your problem is here:

bSpawn = GameObject.Find("bulletSpawn").transform;

You globally search for a “bulletSpawn” object. So Find will always return the same object, no matter from where you run that line of code. Generally the better approach would be to make your bSpawn variable public / serializable and assign the bulletSpawn object within your prefab in the editor. That way each instance of the prefab will reference their own bulletSpawn object automatically.

However if you want to setup the reference through code you have to do a “relative” search using transform.Find. Note that transform.Find does not automatically search for nested children. However you can use a path-like name. Imagine a structure like this:

Prefab Root    // <-- this is where our script is attached
 |
 \-SomeChild
    |
    \-bulletSpawn

You can get the “bulletSpawn” child by doing

bSpawn = transform.Find("SomeChild/bulletSpawn");

If you have a deeply nested structure and you don’t want to specify the whole path i would strongly recommend to setup the reference in the editor. If you still want to do it from code you may want to use this extension method i’ve written. Though keep in mind that the name “bulletSpawn” should be unique within the prefab.