Null Reference Error after build

Hey Guys,
I just started a huge Project and got some problems with the first game. In the editor everything works well but after i build the game sends Null reference errors in a specific gamemode. And crashs within Player3.
Hope Somebody can help me:
Code Follow The Line:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FollowTheLine : MonoBehaviour
{
    public Transform[] waypoints;
    [SerializeField] public float moveSpeed = 1f;

    [HideInInspector] public int waypointIndex = 0;

    public bool moveAllowed = false;

    private void Start()
    {
        transform.position = waypoints[waypointIndex].transform.position;
   


    }
    public void Update()
    {
        if (moveAllowed)
            Move();
        transform.position = waypoints[waypointIndex].transform.position;
    }




    public void Move()
    {
        if (waypointIndex <=waypoints.Length - 1)
        {
            transform.position = Vector2.MoveTowards(transform.position,
                waypoints[waypointIndex].transform.position,
                moveSpeed * Time.deltaTime);

            if (transform.position == waypoints[waypointIndex].transform.position)
            {
                waypointIndex += 1;
            }
        }
    }
}

The LadderControll skript:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LadderControl : MonoBehaviour
{

    public static GameObject player1MoveText, player2MoveText, player3MoveText, player4MoveText, player5MoveText, player6MoveText, player7MoveText, player8MoveText, player12MoveText;
    public static GameObject player1, player2, player3, player4, player5, player6, player7, player8, player12;
 

    public static int nofPlayers;
    public static int Player1;
    public static int Player2;
    public static int Player3;
    public static int Player4;
    public static int Player5;
    public static int Player6;
    public static int Player7;
    public static int Player8;
    public static int Player12;



    public static int diceSideThrown = 0;
    public static int player1StartWaypoint = 0;
    public static int player2StartWaypoint = 0;
    public static int player3StartWaypoint = 0;
    public static int player4StartWaypoint = 0;
    public static int player5StartWaypoint = 0;
    public static int player6StartWaypoint = 0;
    public static int player7StartWaypoint = 0;
    public static int player8StartWaypoint = 0;
    public static int player12StartWaypoint = 0;


    public static bool gameOver = false;

    public void Start()
    {
        diceSideThrown = 0;
        player1StartWaypoint = 0;
        player2StartWaypoint = 0;
        player2StartWaypoint = 0;
        player3StartWaypoint = 0;
        player4StartWaypoint = 0;
        player5StartWaypoint = 0;
        player6StartWaypoint = 0;
        player7StartWaypoint = 0;
        player8StartWaypoint = 0;
        player12StartWaypoint = 0;
 
        gameOver = false;

        //Objekte finden
        player1MoveText = GameObject.Find("P1Move");
        player2MoveText = GameObject.Find("P2Move");
        player3MoveText = GameObject.Find("P3Move");
        player4MoveText = GameObject.Find("P4Move");
        player5MoveText = GameObject.Find("P5Move");
        player6MoveText = GameObject.Find("P6Move");
        player7MoveText = GameObject.Find("P7Move");
        player8MoveText = GameObject.Find("P8Move");
        player12MoveText = GameObject.Find("P9Move");


        player1 = GameObject.Find("Player1");
        player2 = GameObject.Find("Player2");
        player3 = GameObject.Find("Player3");
        player4 = GameObject.Find("Player4");
        player5 = GameObject.Find("Player5");
        player6 = GameObject.Find("Player6");
        player7 = GameObject.Find("Player7");
        player8 = GameObject.Find("Player8");
        player12 = GameObject.Find("Player12");
  

        player1.GetComponent<FollowTheLine>().moveAllowed = false;
        player2.GetComponent<FollowTheLine>().moveAllowed = false;
        player3.GetComponent<FollowTheLine>().moveAllowed = false;
        player4.GetComponent<FollowTheLine>().moveAllowed = false;
        player5.GetComponent<FollowTheLine>().moveAllowed = false;
        player6.GetComponent<FollowTheLine>().moveAllowed = false;
        player7.GetComponent<FollowTheLine>().moveAllowed = false;
        player8.GetComponent<FollowTheLine>().moveAllowed = false;
        player12.GetComponent<FollowTheLine>().moveAllowed = false;
        //player10.GetComponent<FollowTheLine>().moveAllowed = false;

        //whoWinsTextShadow.gameObject.SetActive(false);
        //player1MoveText.gameObject.SetActive(true);
        //player2MoveText.gameObject.SetActive(false);



    }

    public void Update()
    {

        if (RollDice.whosTurn == 1)
        {
            player1MoveText.gameObject.SetActive(true);
            player2MoveText.gameObject.SetActive(false);
            player3MoveText.gameObject.SetActive(false);
            player4MoveText.gameObject.SetActive(false);
            player5MoveText.gameObject.SetActive(false);
            player6MoveText.gameObject.SetActive(false);
            player7MoveText.gameObject.SetActive(false);
            player8MoveText.gameObject.SetActive(false);
            player12MoveText.gameObject.SetActive(false);
            //player10MoveText.gameObject.SetActive(false);
        }
        else if (RollDice.whosTurn == 2)
        {
            player1MoveText.gameObject.SetActive(false);
            player2MoveText.gameObject.SetActive(true);
            player3MoveText.gameObject.SetActive(false);
            player4MoveText.gameObject.SetActive(false);
            player5MoveText.gameObject.SetActive(false);
            player6MoveText.gameObject.SetActive(false);
            player7MoveText.gameObject.SetActive(false);
            player8MoveText.gameObject.SetActive(false);
            player12MoveText.gameObject.SetActive(false);
            //player10MoveText.gameObject.SetActive(false);
        }
        else if (RollDice.whosTurn == 3)
        {
            player1MoveText.gameObject.SetActive(false);
            player2MoveText.gameObject.SetActive(false);
            player3MoveText.gameObject.SetActive(true);
            player4MoveText.gameObject.SetActive(false);
            player5MoveText.gameObject.SetActive(false);
            player6MoveText.gameObject.SetActive(false);
            player7MoveText.gameObject.SetActive(false);
            player8MoveText.gameObject.SetActive(false);
            player12MoveText.gameObject.SetActive(false);
            //player10MoveText.gameObject.SetActive(false);
        }
        else if (RollDice.whosTurn == 4)
        {
            player1MoveText.gameObject.SetActive(false);
            player2MoveText.gameObject.SetActive(false);
            player3MoveText.gameObject.SetActive(false);
            player4MoveText.gameObject.SetActive(true);
            player5MoveText.gameObject.SetActive(false);
            player6MoveText.gameObject.SetActive(false);
            player7MoveText.gameObject.SetActive(false);
            player8MoveText.gameObject.SetActive(false);
            player12MoveText.gameObject.SetActive(false);
            //player10MoveText.gameObject.SetActive(false);
        }
        else if (RollDice.whosTurn == 5)
        {
            player1MoveText.gameObject.SetActive(false);
            player2MoveText.gameObject.SetActive(false);
            player3MoveText.gameObject.SetActive(false);
            player4MoveText.gameObject.SetActive(false);
            player5MoveText.gameObject.SetActive(true);
            player6MoveText.gameObject.SetActive(false);
            player7MoveText.gameObject.SetActive(false);
            player8MoveText.gameObject.SetActive(false);
            player12MoveText.gameObject.SetActive(false);
            //player10MoveText.gameObject.SetActive(false);
        }
        else if (RollDice.whosTurn == 6)
        {
            player1MoveText.gameObject.SetActive(false);
            player2MoveText.gameObject.SetActive(false);
            player3MoveText.gameObject.SetActive(false);
            player4MoveText.gameObject.SetActive(false);
            player5MoveText.gameObject.SetActive(false);
            player6MoveText.gameObject.SetActive(true);
            player7MoveText.gameObject.SetActive(false);
            player8MoveText.gameObject.SetActive(false);
            player12MoveText.gameObject.SetActive(false);
            //player10MoveText.gameObject.SetActive(false);
        }
        else if (RollDice.whosTurn == 7)
        {
            player1MoveText.gameObject.SetActive(false);
            player2MoveText.gameObject.SetActive(false);
            player3MoveText.gameObject.SetActive(false);
            player4MoveText.gameObject.SetActive(false);
            player5MoveText.gameObject.SetActive(false);
            player6MoveText.gameObject.SetActive(false);
            player7MoveText.gameObject.SetActive(true);
            player8MoveText.gameObject.SetActive(false);
            player12MoveText.gameObject.SetActive(false);
            //player10MoveText.gameObject.SetActive(false);
        }
        else if (RollDice.whosTurn == 8)
        {
            player1MoveText.gameObject.SetActive(false);
            player2MoveText.gameObject.SetActive(false);
            player3MoveText.gameObject.SetActive(false);
            player4MoveText.gameObject.SetActive(false);
            player5MoveText.gameObject.SetActive(false);
            player6MoveText.gameObject.SetActive(false);
            player7MoveText.gameObject.SetActive(false);
            player8MoveText.gameObject.SetActive(true);
            player12MoveText.gameObject.SetActive(false);
            //player10MoveText.gameObject.SetActive(false);

        }
        else if (RollDice.whosTurn == 9)
        {
            player1MoveText.gameObject.SetActive(false);
            player2MoveText.gameObject.SetActive(false);
            player3MoveText.gameObject.SetActive(false);
            player4MoveText.gameObject.SetActive(false);
            player5MoveText.gameObject.SetActive(false);
            player6MoveText.gameObject.SetActive(false);
            player7MoveText.gameObject.SetActive(false);
            player8MoveText.gameObject.SetActive(false);
            player12MoveText.gameObject.SetActive(true);
            //player10MoveText.gameObject.SetActive(false);
        }
        //else if (RollDice.whosTurn == 10)
        //{
        //    player1MoveText.gameObject.SetActive(false);
        //    player2MoveText.gameObject.SetActive(false);
        //    player3MoveText.gameObject.SetActive(false);
        //    player4MoveText.gameObject.SetActive(false);
        //    player5MoveText.gameObject.SetActive(false);
        //    player6MoveText.gameObject.SetActive(false);
        //    player7MoveText.gameObject.SetActive(false);
        //    player8MoveText.gameObject.SetActive(false);
        //    player9MoveText.gameObject.SetActive(false);
        //    player10MoveText.gameObject.SetActive(true);
        //}
        //Player 1
        if (player1.GetComponent<FollowTheLine>().waypointIndex >
            player1StartWaypoint + diceSideThrown)
        {
            if (player1StartWaypoint + diceSideThrown == 15)
            {
                player1.GetComponent<FollowTheLine>().transform.position = player1.GetComponent<FollowTheLine>().waypoints[1].transform.position;
                player1.GetComponent<FollowTheLine>().waypointIndex = 1;
                player1.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(1);
            }
            if (player1StartWaypoint + diceSideThrown == 22)
            {
                player1.GetComponent<FollowTheLine>().transform.position = player1.GetComponent<FollowTheLine>().waypoints[12].transform.position;
                player1.GetComponent<FollowTheLine>().waypointIndex = 12;
                player1.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(1);
            }
            if (player1StartWaypoint + diceSideThrown == 33)
            {
                player1.GetComponent<FollowTheLine>().transform.position = player1.GetComponent<FollowTheLine>().waypoints[19].transform.position;
                player1.GetComponent<FollowTheLine>().waypointIndex = 19;
                player1.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(1);
            }
            player1.GetComponent<FollowTheLine>().moveAllowed = false;
            player1StartWaypoint = player1.GetComponent<FollowTheLine>().waypointIndex - 1;
        }
        //Player 2
        else if (player2.GetComponent<FollowTheLine>().waypointIndex >
            player2StartWaypoint + diceSideThrown)
        {

            if (player2StartWaypoint + diceSideThrown == 15)
            {
                player2.GetComponent<FollowTheLine>().transform.position = player2.GetComponent<FollowTheLine>().waypoints[1].transform.position;
                player2.GetComponent<FollowTheLine>().waypointIndex = 1;
                player2.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(2);
            }
            if (player2StartWaypoint + diceSideThrown == 22)
            {
                player2.GetComponent<FollowTheLine>().transform.position = player2.GetComponent<FollowTheLine>().waypoints[12].transform.position;
                player2.GetComponent<FollowTheLine>().waypointIndex = 12;
                player2.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(2);
            }
            if (player2StartWaypoint + diceSideThrown == 33)
            {
                player2.GetComponent<FollowTheLine>().transform.position = player2.GetComponent<FollowTheLine>().waypoints[19].transform.position;
                player2.GetComponent<FollowTheLine>().waypointIndex = 19;
                player2.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(2);
            }
            player2.GetComponent<FollowTheLine>().moveAllowed = false;
          
            player2StartWaypoint = player2.GetComponent<FollowTheLine>().waypointIndex - 1;
        }
        //Player 3
        else if (player3.GetComponent<FollowTheLine>().waypointIndex >
            player3StartWaypoint + diceSideThrown)
        {

            if (player3StartWaypoint + diceSideThrown == 15)
            {
                player3.GetComponent<FollowTheLine>().transform.position = player3.GetComponent<FollowTheLine>().waypoints[1].transform.position;
                player3.GetComponent<FollowTheLine>().waypointIndex = 1;
                player3.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(3);
            }
            if (player3StartWaypoint + diceSideThrown == 22)
            {
                player3.GetComponent<FollowTheLine>().transform.position = player3.GetComponent<FollowTheLine>().waypoints[12].transform.position;
                player3.GetComponent<FollowTheLine>().waypointIndex = 12;
                player3.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(3);
            }
            if (player3StartWaypoint + diceSideThrown == 33)
            {
                player3.GetComponent<FollowTheLine>().transform.position = player3.GetComponent<FollowTheLine>().waypoints[19].transform.position;
                player3.GetComponent<FollowTheLine>().waypointIndex = 19;
                player3.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(3);
            }
            player3.GetComponent<FollowTheLine>().moveAllowed = false;

            player3StartWaypoint = player3.GetComponent<FollowTheLine>().waypointIndex - 1;
        }
        //Player 4
        else if (player4.GetComponent<FollowTheLine>().waypointIndex >
            player4StartWaypoint + diceSideThrown)
        {
            if (player4StartWaypoint + diceSideThrown == 15)
            {
                player4.GetComponent<FollowTheLine>().transform.position = player4.GetComponent<FollowTheLine>().waypoints[1].transform.position;
                player4.GetComponent<FollowTheLine>().waypointIndex = 1;
                player4.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(4);
            }
            if (player4StartWaypoint + diceSideThrown == 22)
            {
                player4.GetComponent<FollowTheLine>().transform.position = player4.GetComponent<FollowTheLine>().waypoints[12].transform.position;
                player4.GetComponent<FollowTheLine>().waypointIndex = 12;
                player4.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(4);
            }
            if (player4StartWaypoint + diceSideThrown == 33)
            {
                player4.GetComponent<FollowTheLine>().transform.position = player4.GetComponent<FollowTheLine>().waypoints[19].transform.position;
                player4.GetComponent<FollowTheLine>().waypointIndex = 19;
                player4.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(4);
            }
            player4.GetComponent<FollowTheLine>().moveAllowed = false;
            player4StartWaypoint = player4.GetComponent<FollowTheLine>().waypointIndex - 1;
        }
        //Player 5
        else if (player5.GetComponent<FollowTheLine>().waypointIndex >
            player5StartWaypoint + diceSideThrown)
        {
            if (player5StartWaypoint + diceSideThrown == 15)
            {
                player5.GetComponent<FollowTheLine>().transform.position = player5.GetComponent<FollowTheLine>().waypoints[1].transform.position;
                player5.GetComponent<FollowTheLine>().waypointIndex = 1;
                player5.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(5);
            }
            if (player5StartWaypoint + diceSideThrown == 22)
            {
                player5.GetComponent<FollowTheLine>().transform.position = player5.GetComponent<FollowTheLine>().waypoints[12].transform.position;
                player5.GetComponent<FollowTheLine>().waypointIndex = 12;
                player5.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(5);
            }
            if (player5StartWaypoint + diceSideThrown == 33)
            {
                player5.GetComponent<FollowTheLine>().transform.position = player5.GetComponent<FollowTheLine>().waypoints[19].transform.position;
                player5.GetComponent<FollowTheLine>().waypointIndex = 19;
                player5.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(5);
            }
            player5.GetComponent<FollowTheLine>().moveAllowed = false;
            player5StartWaypoint = player5.GetComponent<FollowTheLine>().waypointIndex - 1;
        }
        //Player 6
        else if (player6.GetComponent<FollowTheLine>().waypointIndex >
            player6StartWaypoint + diceSideThrown)
        {
            if (player6StartWaypoint + diceSideThrown == 15)
            {
                player6.GetComponent<FollowTheLine>().transform.position = player6.GetComponent<FollowTheLine>().waypoints[1].transform.position;
                player6.GetComponent<FollowTheLine>().waypointIndex = 1;
                player6.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(6);
            }
            if (player6StartWaypoint + diceSideThrown == 22)
            {
                player6.GetComponent<FollowTheLine>().transform.position = player6.GetComponent<FollowTheLine>().waypoints[12].transform.position;
                player6.GetComponent<FollowTheLine>().waypointIndex = 12;
                player6.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(6);
            }
            if (player6StartWaypoint + diceSideThrown == 33)
            {
                player6.GetComponent<FollowTheLine>().transform.position = player6.GetComponent<FollowTheLine>().waypoints[19].transform.position;
                player6.GetComponent<FollowTheLine>().waypointIndex = 19;
                player6.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(6);
            }
            player6.GetComponent<FollowTheLine>().moveAllowed = false;
            player6StartWaypoint = player6.GetComponent<FollowTheLine>().waypointIndex - 1;
        }
        //Player 7
        else if (player7.GetComponent<FollowTheLine>().waypointIndex >
            player7StartWaypoint + diceSideThrown)
        {
            if (player7StartWaypoint + diceSideThrown == 15)
            {
                player7.GetComponent<FollowTheLine>().transform.position = player7.GetComponent<FollowTheLine>().waypoints[1].transform.position;
                player7.GetComponent<FollowTheLine>().waypointIndex = 1;
                player7.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(7);
            }
            if (player7StartWaypoint + diceSideThrown == 22)
            {
                player7.GetComponent<FollowTheLine>().transform.position = player7.GetComponent<FollowTheLine>().waypoints[12].transform.position;
                player7.GetComponent<FollowTheLine>().waypointIndex = 12;
                player7.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(7);
            }
            if (player7StartWaypoint + diceSideThrown == 33)
            {
                player7.GetComponent<FollowTheLine>().transform.position = player7.GetComponent<FollowTheLine>().waypoints[19].transform.position;
                player7.GetComponent<FollowTheLine>().waypointIndex = 19;
                player7.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(7);
            }
            player7.GetComponent<FollowTheLine>().moveAllowed = false;
            player7StartWaypoint = player7.GetComponent<FollowTheLine>().waypointIndex - 1;
        }
        //Player 8
        else if (player8.GetComponent<FollowTheLine>().waypointIndex >
            player8StartWaypoint + diceSideThrown)
        {
            if (player8StartWaypoint + diceSideThrown == 15)
            {
                player8.GetComponent<FollowTheLine>().transform.position = player8.GetComponent<FollowTheLine>().waypoints[1].transform.position;
                player8.GetComponent<FollowTheLine>().waypointIndex = 1;
                player8.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(8);
            }
            if (player8StartWaypoint + diceSideThrown == 22)
            {
                player8.GetComponent<FollowTheLine>().transform.position = player8.GetComponent<FollowTheLine>().waypoints[12].transform.position;
                player8.GetComponent<FollowTheLine>().waypointIndex = 12;
                player8.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(8);
            }
            if (player8StartWaypoint + diceSideThrown == 33)
            {
                player8.GetComponent<FollowTheLine>().transform.position = player8.GetComponent<FollowTheLine>().waypoints[19].transform.position;
                player8.GetComponent<FollowTheLine>().waypointIndex = 19;
                player8.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(8);
            }
            player8.GetComponent<FollowTheLine>().moveAllowed = false;
            player8StartWaypoint = player8.GetComponent<FollowTheLine>().waypointIndex - 1;
        }
        //Player 9
        else if (player12.GetComponent<FollowTheLine>().waypointIndex >
             player12StartWaypoint + diceSideThrown)
        {
            if (player12StartWaypoint + diceSideThrown == 15)
            {
                player12.GetComponent<FollowTheLine>().transform.position = player12.GetComponent<FollowTheLine>().waypoints[1].transform.position;
                player12.GetComponent<FollowTheLine>().waypointIndex = 1;
                player12.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(12);
            }
            if (player12StartWaypoint + diceSideThrown == 22)
            {
                player12.GetComponent<FollowTheLine>().transform.position = player12.GetComponent<FollowTheLine>().waypoints[12].transform.position;
                player12.GetComponent<FollowTheLine>().waypointIndex = 12;
                player12.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(12);
            }
            if (player12StartWaypoint + diceSideThrown == 33)
            {
                player12.GetComponent<FollowTheLine>().transform.position = player12.GetComponent<FollowTheLine>().waypoints[19].transform.position;
                player12.GetComponent<FollowTheLine>().waypointIndex = 19;
                player12.GetComponent<FollowTheLine>().waypointIndex += 1;
                MovePlayer(12);
            }
            player12.GetComponent<FollowTheLine>().moveAllowed = false;
            player12StartWaypoint = player12.GetComponent<FollowTheLine>().waypointIndex - 1;
        }
        //Player 10
        //if (player10.GetComponent<FollowTheLine>().waypointIndex >
        //    player10StartWaypoint + diceSideThrown)
        //{
        //    player10.GetComponent<FollowTheLine>().moveAllowed = false;
        //    player10StartWaypoint = player10.GetComponent<FollowTheLine>().waypointIndex - 1;
        //}
        //who wins
        //if (player1.GetComponent<FollowTheLine>().waypointIndex ==
        //player1.GetComponent<FollowTheLine>().waypoints.Length)
        //{
        //    whoWinsTextShadow.gameObject.SetActive(true);
        //    whoWinsTextShadow.GetComponent<Text>().text = "Player 1 Wins";
        //    gameOver = true;
        //    player1MoveText.gameObject.SetActive(true);
        //    player2MoveText.gameObject.SetActive(false);
        //    player3MoveText.gameObject.SetActive(false);
        //    player4MoveText.gameObject.SetActive(false);
        //    player5MoveText.gameObject.SetActive(false);
        //    player6MoveText.gameObject.SetActive(false);
        //    player7MoveText.gameObject.SetActive(false);
        //    player8MoveText.gameObject.SetActive(false);
        //    player12MoveText.gameObject.SetActive(false);
        //}
        //if (player2.GetComponent<FollowTheLine>().waypointIndex ==
        //player2.GetComponent<FollowTheLine>().waypoints.Length)
        //{
        //    whoWinsTextShadow.gameObject.SetActive(true);
        //    whoWinsTextShadow.GetComponent<Text>().text = "Player 2 Wins";
        //    gameOver = true;
        //}
        //if (player3.GetComponent<FollowTheLine>().waypointIndex ==
        //player3.GetComponent<FollowTheLine>().waypoints.Length)
        //{
        //    whoWinsTextShadow.gameObject.SetActive(true);
        //    whoWinsTextShadow.GetComponent<Text>().text = "Player 3 Wins";
        //    gameOver = true;
        //}
        //if (player4.GetComponent<FollowTheLine>().waypointIndex ==
        //player4.GetComponent<FollowTheLine>().waypoints.Length)
        //{
        //    whoWinsTextShadow.gameObject.SetActive(true);
        //    whoWinsTextShadow.GetComponent<Text>().text = "Player 4 Wins";
        //    gameOver = true;
        //}
        //if (player5.GetComponent<FollowTheLine>().waypointIndex ==
        //player5.GetComponent<FollowTheLine>().waypoints.Length)
        //{
        //    whoWinsTextShadow.gameObject.SetActive(true);
        //    whoWinsTextShadow.GetComponent<Text>().text = "Player 5 Wins";
        //    gameOver = true;
        //}
        //if (player6.GetComponent<FollowTheLine>().waypointIndex ==
        //player6.GetComponent<FollowTheLine>().waypoints.Length)
        //{
        //    whoWinsTextShadow.gameObject.SetActive(true);
        //    whoWinsTextShadow.GetComponent<Text>().text = "Player 6 Wins";
        //    gameOver = true;
        //}
        //if (player7.GetComponent<FollowTheLine>().waypointIndex ==
        //player7.GetComponent<FollowTheLine>().waypoints.Length)
        //{
        //    whoWinsTextShadow.gameObject.SetActive(true);
        //    whoWinsTextShadow.GetComponent<Text>().text = "Player 7 Wins";
        //    gameOver = true;
        //}
        //if (player8.GetComponent<FollowTheLine>().waypointIndex ==
        //player8.GetComponent<FollowTheLine>().waypoints.Length)
        //{
        //    whoWinsTextShadow.gameObject.SetActive(true);
        //    whoWinsTextShadow.GetComponent<Text>().text = "Player 8 Wins";
        //    gameOver = true;
        //}
        //if (player9.GetComponent<FollowTheLine>().waypointIndex ==
        //player9.GetComponent<FollowTheLine>().waypoints.Length)
        //{
        //    whoWinsTextShadow.gameObject.SetActive(true);
        //    whoWinsTextShadow.GetComponent<Text>().text = "Player 9 Wins";
        //    gameOver = true;
        //}
        //if (player10.GetComponent<FollowTheLine>().waypointIndex ==
        //player10.GetComponent<FollowTheLine>().waypoints.Length)
        //{
        //    whoWinsTextShadow.gameObject.SetActive(true);
        //    whoWinsTextShadow.GetComponent<Text>().text = "Player 10 Wins";
        //    gameOver = true;
        //}

        if (nofPlayers == 1)
        {
            player1.SetActive(true);
            player2.SetActive(false);
            player3.SetActive(false);
            player4.SetActive(false);
            player5.SetActive(false);
            player6.SetActive(false);
            player7.SetActive(false);
            player8.SetActive(false);
            player12.SetActive(false);
        }
        else if (nofPlayers == 2)
        {
            player1.SetActive(true);
            player2.SetActive(true);
            player3.SetActive(false);
            player4.SetActive(false);
            player5.SetActive(false);
            player6.SetActive(false);
            player7.SetActive(false);
            player8.SetActive(false);
            player12.SetActive(false);
        }
        else if (nofPlayers == 3)
        {
            player1.SetActive(true);
            player2.SetActive(true);
            player3.SetActive(true);
            player4.SetActive(false);
            player5.SetActive(false);
            player6.SetActive(false);
            player7.SetActive(false);
            player8.SetActive(false);
            player12.SetActive(false);
        }
        else if (nofPlayers == 4)
        {
            player1.SetActive(true);
            player2.SetActive(true);
            player3.SetActive(true);
            player4.SetActive(true);
            player5.SetActive(false);
            player6.SetActive(false);
            player7.SetActive(false);
            player8.SetActive(false);
            player12.SetActive(false);
        }
        else if (nofPlayers == 5)
        {
            player1.SetActive(true);
            player2.SetActive(true);
            player3.SetActive(true);
            player4.SetActive(true);
            player5.SetActive(true);
            player6.SetActive(false);
            player7.SetActive(false);
            player8.SetActive(false);
            player12.SetActive(false);
        }
        else if (nofPlayers == 6)
        {
            player1.SetActive(true);
            player2.SetActive(true);
            player3.SetActive(true);
            player4.SetActive(true);
            player5.SetActive(true);
            player6.SetActive(true);
            player7.SetActive(false);
            player8.SetActive(false);
            player12.SetActive(false);
        }
        else if (nofPlayers == 7)
        {
            player1.SetActive(true);
            player2.SetActive(true);
            player3.SetActive(true);
            player4.SetActive(true);
            player5.SetActive(true);
            player6.SetActive(true);
            player7.SetActive(true);
            player8.SetActive(false);
            player12.SetActive(false);
        }
        else if (nofPlayers == 8)
        {
            player1.SetActive(true);
            player2.SetActive(true);
            player3.SetActive(true);
            player4.SetActive(true);
            player5.SetActive(true);
            player6.SetActive(true);
            player7.SetActive(true);
            player8.SetActive(true);
            player12.SetActive(false);
        }
        else if (nofPlayers == 9)
        {
            player1.SetActive(true);
            player2.SetActive(true);
            player3.SetActive(true);
            player4.SetActive(true);
            player5.SetActive(true);
            player6.SetActive(true);
            player7.SetActive(true);
            player8.SetActive(true);
            player12.SetActive(true);
        }
    }
    public static void MovePlayer(int playerToMove)
    {
        switch (playerToMove)
        {
            case 1:
                player1.GetComponent<FollowTheLine>().moveAllowed = true;
                break;

            case 2:
                player2.GetComponent<FollowTheLine>().moveAllowed = true;
                break;
            case 3:
                player3.GetComponent<FollowTheLine>().moveAllowed = true;
                break;
            case 4:
                player4.GetComponent<FollowTheLine>().moveAllowed = true;
                break;
            case 5:
                player5.GetComponent<FollowTheLine>().moveAllowed = true;
                break;
            case 6:
                player6.GetComponent<FollowTheLine>().moveAllowed = true;
                break;
            case 7:
                player7.GetComponent<FollowTheLine>().moveAllowed = true;
                break;
            case 8:
                player8.GetComponent<FollowTheLine>().moveAllowed = true;
                break;
            case 9:
                player12.GetComponent<FollowTheLine>().moveAllowed = true;
                break;
        
        }
    }
}

And the Error is:
NullReferenceException: Object reference not set to an instance of an object
at LadderControl.Start () [0x00177] in D:\Users\daniel_diezel\entwicklung\test\party_games\Assets\Scripts\MultiplayerLadder\LadderControl.cs:89

(Filename: D:/Users/daniel_diezel/entwicklung/test/party_games/Assets/Scripts/MultiplayerLadder/LadderControl.cs Line: 81)

NullReferenceException: Object reference not set to an instance of an object
at LadderControl.Update () [0x00998] in D:\Users\daniel_diezel\entwicklung\test\party_games\Assets\Scripts\MultiplayerLadder\LadderControl.cs:291

(Filename: D:/Users/daniel_diezel/entwicklung/test/party_games/Assets/Scripts/MultiplayerLadder/LadderControl.cs Line: 291)

The error messages don’t make any sense, as in, they’re just not possible with this code. The first one points to an empty line, and the second one points to a line that comes after two other lines that already access the same object (and would have triggered the NRE before that line). Those errors are being generated by code that is definitely not the code that is posted, so presumably not the code you thought you were building with. I’m wondering if maybe your build failed and you didn’t notice, and ran a build you already had in that location, so the errors are from an older build? Something like that?

2 Likes

The answer is always the same… ALWAYS. It is the single most common error ever.

Don’t waste your life spinning around and round on this error. Instead, learn how to fix it fast… it’s EASY!!

Some notes on how to fix a NullReferenceException error in Unity3D

  • also known as: Unassigned Reference Exception
  • also known as: Missing Reference Exception
  • also known as: Object reference not set to an instance of an object

http://plbm.com/?p=221

The basic steps outlined above are:

  • Identify what is null
  • Identify why it is null
  • Fix that.

Expect to see this error a LOT. It’s easily the most common thing to do when working. Learn how to fix it rapidly. It’s easy. See the above link for more tips.

This is the kind of mindset and thinking process you need to bring to this problem:

https://discussions.unity.com/t/814091/4

Step by step, break it down, find the problem.

It usually is, but honestly, sometimes you gotta read the thread before you paste this… this advice is useless here, see above.

Line number are often wrong when pasted in here, either for mixed Unix/Windows line endings or for other reasons.

The fact that it says LadderControl.cs:299 in the error and the fact that there are “hairy lines of code” such as the MASSIVE number of get.get.get.get.foo = get.get.get.get.bat; constructs, I guarantee that’s his error and only he will find it when he unravels which object doesn’t have a FollowTheLine, or which player is null.

Guaranteed.

EDIT: or who doesn’t have a properly initialized waypoints[ ] array.

Please, use Array or List. You just add completely unnecessary complexity for yourself.

Otherwise follow the instructions above and you’ll find what is null.

1 Like

Last time I had null references in build it was because I erroneously had objects tagged with the ‘EditorOnly’ tag, of which gets stripped out in build. Could be the error here.

1 Like

__
Hey sorry but the error in this code points to line 291 and 81 in the LadderControllScript. not as its displayed here.

Almost-certainly you:

  • don’t have a gameobject called “Player3” or
  • You do, but it is disabled or
  • You do have an object called Player3 and it is enabled, but it does not have a “FollowTheLine” component attached.

Follow Kurt-Dekkers advice to verify which of these is the case.

Consider learning about arrays/lists. An array/list could turn your 700 line monstrosity into about 50 neat and tidy lines.

1 Like

Hey i checked it out they are all set to untagged.
But thanks for your advice :smile:


Hey Thanks for your advice:
I just tested your way and I saw that in the build scene the Debug Log on Line 81 is not executed. The error is directly when i switch to the scene and the debug.log isnt executed. Now I checked your solution but I cant fix it with that cause you said I have to put it on a GameObject. But the script is attached to the gameObject. So do you have any more solutions?
Thanks in advance

You already knew line 81 wasn’t executing, that was the line that was throwing the null reference exception.

Now do the first step: Identify what is null. Debug.Log the value of player3 and see if it is null or not. Do this right before line 81.

__
Ok i did is infront of line 81:
Debug.Log(“Player3.getComponent().moveAllowed = false”);
and after i build this was infront of the first error: (line 81 is the debug.log and the normal code is line 82)

player3.GetComponent().moveAllowed = false
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[ ])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:Log (object)
LadderControl:Start () (at C:/Users/barmd/Downloads/monopoly-master/Party Game/Assets/Scripts/MultiplayerLadder/LadderControl.cs:81)

(Filename: C:/Users/barmd/Downloads/monopoly-master/Party Game/Assets/Scripts/MultiplayerLadder/LadderControl.cs Line: 81)

That doesn’t log the value of player3, that just prints the string “Player3.getComponent().moveAllowed = false”. That doesn’t do anything useful.

Is player3 null? Find out like this:

Debug.Log("Is player3 null? " + (player3 == null || !player3));


so i added this in Line 71 and now i get this back:

Is player3 null? False
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[ ])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:Log (object)
LadderControl:Start () (at D:/Users/daniel_diezel/entwicklung/test2/party_games/Assets/Scripts/MultiplayerLadder/LadderControl.cs:71)

(Filename: D:/Users/daniel_diezel/entwicklung/test2/party_games/Assets/Scripts/MultiplayerLadder/LadderControl.cs Line: 71)

Now you know player3 is not null. What else could be null on line 81?

player3.GetComponent<FollowTheLine>().moveAllowed

You are accessing the property “moveAllowed” of whatever GetComponent returns. If you look up the documentation, GetComponent() will return null if the GameObject does not have a component of that type on there.

So the problem is whatever GameObject you named Player3 doesn’t have a FollowTheLine component attached. The solution is to attach a FollowTheLine component to it.

1 Like

Hey I just tested it and the Follow the Line component is on the Player3 as you see in this screenshot:

7132550--852497--errorunity.PNG

Than is your “player3” Object the one you expect it to be? Do you have another GameObject called “Player3” somewhere?

Debug.Log("player3 is " + player3, player3);

When you click on this message in the console, Unity will highlight the player3 object in the Hierarchy. Verify it is correct.

__
in the editor everything works fine. So he shows me that Player3 is the Player as shown in the screenshot

7132739--852536--unity higllitg.PNG