Error in accessing variables from another script

I have two prefabs each having its own individual script. I am then loading both prefabs through a third script and need to work between their variables.
Here is what I have done :

public class GameManager : MonoBehaviour {

	public Transform buttonPrefab;
	public Transform playerPrefab;

	private GameObject b;
	private GameObject p;
	private ButtonScript button;
	private PlayerController player;

	// Use this for initialization
	void Start ()
	{
		p = Instantiate (playerPrefab, new Vector3 (0, 0, 0), Quaternion.identity) as GameObject;
		b = Instantiate (buttonPrefab) as GameObject;

		button = b.gameObject.GetComponent<ButtonScript> ();
		player = p.gameObject.GetComponent<PlayerController> ();
	}
	
	// Update is called once per frame
	void Update () 
	{
		if (button.IsClicked)
						player.Move ();
	}
}

But I keep getting the Error:
NullReferenceException: Object reference not set to an instance of an object.

What am I doing wrong ?

EDIT: After restarting Unity the problem was gone. Thanks anyway!

I think instantiating GameObjects from a Transform reference won’t work.

Try changing these lines:

public Transform buttonPrefab;
public Transform playerPrefab;

to:

public GameObject buttonPrefab;
public GameObject playerPrefab;