Instanciated prefabs follow wrong player.

Hello everyone!

I have just started coding and using unity, and Im loving it! Solving issues has been very satisfying, until now. Now, im faced with something which makes me want to slam my computer so far down my throat i can use it by digesting it (i hope that is a good explanation of my rage). Im sure there is an easy fix to my issue, but as I said, im new so idk what that fix is.

The issue:

I have a prefab which is coded to follow the players location at all times. The issue is that, while it says that the target is the player, after i put the players prefab into it, the prefab ends up going to the players spawn location and thats it, while if i change the target of the prefab while it is in the scene with a player that is in the scene it will move with the player. This is an issue as I have a script to instantiate these prefabs into the level, so they all just move to the players spawn location, and it doesnt let me move my in-scene player into the prefabs target tansform when its just the prefab in my assets, not in the scene.

This is my first post, so i dont really know how to give more info, but i would love to give more info on the issue once i understand how to.

This is the code for my enemy (Brakeys lol):

using UnityEngine;
using Pathfinding;

public class MeleeAI : MonoBehaviour
{

    public Transform target;

    public float speed = 40f;
    public float nextWaypoint = 2f;

    Path path;
    int currentWaypoint = 0;
    bool reachedEndPath = false;

    Seeker seeker;
    Rigidbody2D rb;

    void Start()
    {

        seeker = GetComponent<Seeker>();
        rb = GetComponent<Rigidbody2D>();

        InvokeRepeating("UpdatePath", 0f, 0.1f);

    }

    void UpdatePath()
    {

        if (seeker.IsDone())
            seeker.StartPath(rb.position, target.position, OnPathComplete);

    }

    void OnPathComplete(Path p)
    {

        if (!p.error)
        {

            path = p;

            currentWaypoint = 0;

        }

    }

    void FixedUpdate()
    {

        if (path == null)
            return;

        if (currentWaypoint >= path.vectorPath.Count)
        {

            reachedEndPath = true;
            return;

        }

        else
        {

            reachedEndPath = false;

        }

        Vector2 direction = ((Vector2)path.vectorPath[currentWaypoint] - rb.position).normalized;
        Vector2 force = direction * speed * Time.deltaTime;

        rb.AddForce(force * speed);

        float distance = Vector2.Distance(rb.position, path.vectorPath[currentWaypoint]);

        if (distance < nextWaypoint)
        {

            currentWaypoint++;

        }

    }
}

you need to add the player itself to the target, not the player prefab