Target = NetworkedMe

How can I make my Enemy script AI “target” equal to the local player, so that it doesnt goes haywire looking for all of those other players. For now my script looks for the Player tag gameObject, and since in multiplayer the players are all set as Player tag. So how do i make the enemy follow local player? heres the looking for target line of code of the script:

target = GameObject.FindWithTag("Player").transform;

Add a script to the local player that isn’t on the instantiated network players which uses a singleton to identify it:

#LocalPlayer.cs

 public class LocalPlayer : MonoBehaviour
 {
       public static Transform instance;
       void Awake()
       {
            if(instance == null)
                instance = transform;
       }
       void OnDestroy()
       {
           if(instance == transform)
                instance = null;
       }
 }

Then find the local player by doing:

      LocalPlayer.instance