NullRefernceExecption error

using UnityEngine;
using System.Collections;

public class SideViewPlayer : MonoBehaviour {
	public float speed;
	bool rayCastJump;
	bool canJump;
	Rigidbody2D rigidbody2d;
	public float jumpHeight;
	public float hitDistance;

	// Use this for initialization
	void Start () {
		canJump = false;
		rigidbody2d = gameObject.GetComponent<Rigidbody2D>();
	// Update is called once per frame
	void Update () {
		float x = Input.GetAxis ("Horizontal");
		float jump = Input.GetAxis ("Jump");
		transform.Translate (new Vector3 (x * speed * Time.deltaTime, 0, 0));

		RaycastHit2D hit = Physics2D.Raycast (transform.position,-Vector2.up,hitDistance);
		Debug.DrawRay (transform.position, -Vector2.up,;

		if (hit.collider.gameObject.tag != null) {
			if (hit.collider.gameObject.tag == "floor")
				canJump = true;
				canJump = false;

		if ( jump >0&& canJump) {
			rigidbody2d.AddForce(new Vector2(0,jumpHeight));

i’m trying to detect of the player on the floor or not the enable jumping and disable it
the error in in this line if (hit.collider.gameObject.tag == “floor”)

From the API docs of Physics2D.Raycast

This function returns a RaycastHit object with a reference to the collider that is hit by the ray (the collider property of the result will be NULL if nothing was hit).

I guess your ray doesn’t hit the floor when you jump high enough. You should have a null check for the hit.collider