KillPlayer, Null Reference Exception.

Hey there. I’ve been following a tutorial on how to make a basic platformer. I have all the right scripts, but it simply wont work. Here are the scirpts that I tested o my friends game, and suprisingly there it worked.`using UnityEngine;
using System.Collections;

public class LevelManager : MonoBehaviour {

public GameObject currentCheckpoint;

private PlayerController player;

// Use this for initialization
void Start () {
	player = FindObjectOfType<PlayerController>();

}

// Update is called once per frame
void Update () {

}

public void RespawnPlayer()
{
	Debug.Log ("Player Respawns");
	player.transform.position = currentCheckpoint.transform.position;

}

using UnityEngine;
using System.Collections;

public class KillPlayer : MonoBehaviour {

public LevelManager levelManager;

// Use this for initialization
void Start () {
	levelManager = FindObjectOfType<LevelManager>();

}

// Update is called once per frame
void Update () {

}

void OnTriggerEnter2D(Collider2D other)
{
	if(other.name == "Bohater_0")
	{
		levelManager.RespawnPlayer();
	}
}

}
My scene is basically just player, some platform and spikes. The script are linked to the right object, Kill player to spikes, Level Manager to a Level Manager, and i know that i works, because i get the message “Player Respawns”. However the transform position doesnt work, and i get the error. I also set the current checkpoint in the Level Manager. Anyone know how to fix this? If you do then please help me!

Sry for bad script copying, im new here.

You need to make sure that your player is named exactly “Bohater_0”. When you use OnTriggerEnter2D both the Player and the spikes need to have a Rigidbody2D.
if this doesn’t solve the problem post your PlayerController script and tell me the exact error.

P.S. If you’re new I suggest reading the FAQ and user guide:)