NullReferenceException: object reference not set to an instance of an object

I’m pretty basic at C# and I’m trying to create player and it’s physics properties and I get an error when I try to debug the program and I need help. Here are my scripts:

Player:

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {

    public float speed = 50f;
    public float jumpPower = 150f;
    public float maxSpeed = 3;

    public bool grounded;

    private Rigidbody2D rb2d;
    private Animator anim;

    void Start ()
    {

        rb2d = gameObject.GetComponent<Rigidbody2D>();
        anim = gameObject.GetComponent<Animator>();
    }
   
    void Update ()
    {

        anim.SetBool("grounded", grounded);
        anim.SetFloat("speed", Mathf.Abs(Input.GetAxis("Horizontal")));

    }

    void FixedUpdate()
    {

        //moving the player

        float h = Input.GetAxis("Horizontal");

        rb2d.AddForce((Vector2.right * speed) * h);

        //limiting the speed of player

        if (rb2d.velocity.x > maxSpeed)
        {
            rb2d.velocity = new Vector2(maxSpeed, rb2d.velocity.y);
        }

        if(rb2d.velocity.x < -maxSpeed)
        {
            rb2d.velocity = new Vector2(-maxSpeed, rb2d.velocity.y);
        }

    }
}

GroundCheck:

using UnityEngine;
using System.Collections;

public class GroundCheck : MonoBehaviour {

    private Player player;

    void Start ()
    {

        player = gameObject.GetComponent<Player>();

    }
   
    void OnTriggerEnter2D (Collider2D col)
    {

        player.grounded = true;

    }

    void OnTriggerExit2D (Collider2D col)
    {

        player.grounded = false;

    }
}

Here is the error: “NullReferenceException: object reference not set to an instance of an object. GroundCheck.OnTriggerEnter2D (UnityEngine.Collider2d col) (at Assets/Scripts/GroundCheck.cs:18)”

Please help me with this error ASAP.

“NullReferenceException: object reference not set to an instance of an object. GroundCheck.OnTriggerEnter2D (UnityEngine.Collider2d col) (at Assets/Scripts/GroundCheck.cs:18)”

So the exception was thrown inside the “GroundCheck” script’s “OnTriggerEnter2D” function, and the line is 18, which is “player.grounded = true”.
The error is saying that player is not instantiated, which probably refers to:

player = gameObject.GetComponent <Player> (); //player = GetComponent<Player>();

That “Player” component is probably not in the same GameObject as the GroundCheck script.
Make sure you didn’t put this script somewhere else by mistake, and that the Player script is on the same gameobject as the GroundCkeck one and not in a child gameobject or a parent.