Spawning infinite prefabs error?!

This is acctually my first mobile game so i am not so very skilled in developing.

I get the error:

NullReferenceException: Object reference not set to an instance of an object
FileManager.Update () (at Assets/FileManager.cs:29)

when i want to start my game. I have been watching a youtuber named N3K EN for a tutorial for an infinite runner game. i followed his steps but everytime i get this error. the video is called :

Unity Endless Tutorial • 6 • Spawning infinite tiles [Tutorial][C#]

i am using unity 3D.

here is my script:

using System.Collections;
using UnityEngine;

public class FileManager : MonoBehaviour
{
public GameObject tilePrefabs;

private Transform playerTransform;
private float spawnZ = 0.0f;
private float tileLength = 100f;
private int amnTilesOnScreen = 6;

// Use this for initialization
private void Start () {
    playerTransform = GameObject.FindGameObjectWithTag ("Player").transform;

  for(int i = 0; i < amnTilesOnScreen; i++)
    {
        SpawnTile();

    }

}

// Update is called once per frame
private void Update () {
    if(playerTransform.position.z > (spawnZ - amnTilesOnScreen * tileLength))
    {
        SpawnTile();

    }
}

 private void SpawnTile(int prefabIndex = -1)
{

    GameObject go;
    go = Instantiate (tilePrefabs [0]) as GameObject;
    go.transform.SetParent (transform);
    go.transform.position = Vector3.forward * spawnZ;
    spawnZ += tileLength;
}

}

I really hope somebody can help me.
(btw i am sorry for my bad English).

This is an execution problem. It seems like playerTransform.position.z is being called in Update() before it is fully initialized in Start().

Here’s what you can do:

• Use Awake() instead of Start().

• Do the following in your Update():

 if (playerTransform != null && playerTransform.position.z > (spawnZ - amnTilesOnScreen * tileLength)){
      //...your code here
 }

Note that I added a check if the playerTransform is null first before accessing it.

@Nighfox Thanks for your fast reply and help. I followed your steps. here is my code now:

using System.Collections;
using UnityEngine;

public class FileManager : MonoBehaviour
{
public GameObject tilePrefabs;

private Transform playerTransform;
private float spawnZ = 0.0f;
private float tileLength = 100f;
private int amnTilesOnScreen = 6;

// Use this for initialization
private void Awake()
{
    playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
    for (int i = 0; i < amnTilesOnScreen; i++)
    {
        SpawnTile();
    }
}
// Update is called once per frame
private void Update()
{
    if (playerTransform != null && playerTransform.position.z > (spawnZ - amnTilesOnScreen * tileLength))
    {
        SpawnTile();
    }
}
private void SpawnTile(int prefabIndex = -1)
{
    GameObject go;
    go = Instantiate(tilePrefabs[0]) as GameObject;
    go.transform.SetParent(transform);
    go.transform.position = Vector3.forward * spawnZ;
    spawnZ += tileLength;

}

}

but now i get the error:

NullReferenceException: Object reference not set to an instance of an object
FileManager.Awake () (at Assets/FileManager.cs:16)

do you know how to solve this?