how to fix null reference excpetion:object not set to an instance of an object

using UnityEngine;
using System.Collections;

public class enemy : MonoBehaviour
{
    public float speed = 1;
    Vector3 targetPos;
    GameObject ballObj;

    void Start()
    {
        ballObj = GameObject.FindGameObjectWithTag("Ball");
    }

    void Update()
    {
        targetPos = Vector3.Lerp(transform.position, ballObj.transform.position, Time.deltaTime * speed);

        transform.position = new Vector3(4, targetPos.y, 0);
    }
}

How am I even supposed to answer this when A) You don’t even highlight the line with the error, and B) I don’t even know your setup.

From what I can tell, you most likely don’t have an object with the tag “Ball”.

@NoseKills the ball in unity is tagged with “ball” it still doesn’t work. When I hit start in scenes it says that object is not set to instance and tells me that error is in line 17.