SpaceBar "Jump" not working

Hello! I have this script/animation controller setup to idle, walk and suppose to jump.

I plan on adding run next. However, spacebar “jump” will not trigger. I get an error in my console when hitting spacebar. I appreciate any insight/advice/guidance! thank you!

NullReferenceException: Object reference not set to an instance of an object
PlayerControllerv3.Jump () (at Assets/Scripts/Player_v3/PlayerControllerv3.cs:30)
PlayerControllerv3.Update () (at Assets/Scripts/Player_v3/PlayerControllerv3.cs:21)

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

public class PlayerControllerv3 : MonoBehaviour
{
    public Animator anim;
    private Rigidbody rb;
    public LayerMask layerMask;
    public bool grounded;
    

    void Start()
    {
	this.rb.GetComponent<Rigidbody>();        
    }
    
    private void Update()
    {
	Grounded();
	Jump();
	Move();
    }


    private void Jump()
    {
	if(Input.GetKeyDown(KeyCode.Space) && !this.grounded)
	{
	    this.rb.AddForce(Vector3.up * 80, ForceMode.Impulse);
	}

    }

    
    private void Grounded()
    {
	if(Physics.CheckSphere(this.transform.position + Vector3.down, 0.2f, layerMask))
	{
	    this.grounded = true;
	}
	else
	{
	    this.grounded = false;
	}

	this.anim.SetBool("jump", this.grounded);
    }


    private void Move()
    {
	float verticalAxis = Input.GetAxis("Vertical");
	float horizontalAxis = Input.GetAxis("Horizontal");

	Vector3 movement = this.transform.forward * verticalAxis + this.transform.right * horizontalAxis;
	movement.Normalize();

	this.transform.position += movement * .2f;

	this.anim.SetFloat ("vertical", verticalAxis);
	this.anim.SetFloat ("horizontal", horizontalAxis);
    }
}

Try to remove this. from that line. You already cashing it in Start() so you don’t have to do it again.
Anyway there is too many this it this code lol :slightly_smiling_face:
Or try to change && !this.grounded) to && !grounded (without this).

Change this line:

To this:

rb = GetComponent<Rigidbody>();

That should fix it, as for why: The issue NullReferenceException shows up when you are trying to access or modify a parameter that is null, in this case I think you simply need to properly assign Rigidbody,
this.rb.GetComponent<Rigidbody>(); simply reads the component and doesn’t assign it.