Null LineRenderer in gameobjects with the same script

I’m having an issue where the line renderer is null in certain objects, even though the objects are of the same type. In other words, these objects all have the same script that holds a line renderer, but some have a null line renderer and others don’t. The Start method adds the line renderer component to each object and stores the reference, so I know that the line is being made. But for some reason, certain objects still have a null line renderer when the line is used in another method. Here is the code that sets up the line renderer:

    public List<Checkpoint> Checkpoints;
    public LineRenderer lineRenderer;

    void Start()
    {
        lineRenderer = gameObject.AddComponent<LineRenderer>();
        lineRenderer.SetVertexCount(Checkpoints.Count);
        lineRenderer.SetWidth(0.5f, 0.5f);
        for (int i = 0; i < Checkpoints.Count; i++)
        {
            lineRenderer.SetPosition(i, Checkpoints*.GetPosition());*

}
lineRenderer.enabled = false;
}
Here is the code that shows the line:
void Update()
{
if (lineRenderer.enabled)
{
for (int i = 0; i < Checkpoints.Count; i++)
{
lineRenderer.SetPosition(i, Checkpoints*.GetPosition());*
}
}
}

public void DisplayLine(bool display)
{
if (lineRenderer == null)
{
lineRenderer = gameObject.GetComponent();
}

lineRenderer.enabled = display;
}
The issue is in the DisplayLine method. For some reason, when I call this method, lineRenderer is null, even thought I initialize it on Start() and the debugger tells me that lineRenderer is initialized. Even the GetComponent() method returns null when the Inspector shows that the component is on the game object. This issue is only happening with certain objects and I’m not sure how to fix it.

It sounds like DisplayLine() is being called before the object has properly instantiated. That would explain why GetComponent also failed. You need to make sure the object has called Start() before you ever call DisplayLine().