Enemy Spawning, keeping target assignments when making an object into a prefab.

Sorry if the title is vague, I’m not completely sure how to describe this issue.

I’ve got a basic AI script where I’ll assign an object for the enemy to chase. The problem is, when I turn the enemy into a prefab, the target assignment becomes blank and I cannot alter it while it’s a prefab. I’ve tried to assign the object within the code itself but I’m not completely sure how to do so (I’ve tried a number of things but nothing has panned out).

Any tips on how to fix the first problem, or just how to assign a target within code would be very helpful. C# would be the preferred language for code.

If the target is the player you could tag the player as “Player” and then find the player using

Transform target;

void Start() {
    target = GameObject.FindObjectWithTag("Player").transform;
}