How do i move in the direction i'm looking at

I don’t know a lot about scripting, all i know is how to do make a simple movement script and a quit game script. I want to move in the direction I’m looking at but i don’t know how to do it, can someone please help? Heres my script

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

[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour
{
public Rigidbody Player;
public Camera Camera;
public Vector3 jump;
public float jumpForce = 2.0f;

public bool isGrounded;
Rigidbody rb;
void Start(){
    rb = GetComponent<Rigidbody>();
    jump = new Vector3(0.0f, 2.0f, 0.0f);
    Cursor.visible = false;
    Cursor.lockState = CursorLockMode.Locked;
}

void OnCollisionStay(){
    isGrounded = true;
}

// Update is called once per frame
void Update()
{
    if (Input.GetKey("d")) 
    {
        Player.AddForce(4, 0, 0);
    }

    if (Input.GetKey("a")) 
    {
        Player.AddForce(-4, 0, 0);
    }

    if (Input.GetKey("w")) 
    {
        Player.AddForce(0, 0, 4);
    }

    if (Input.GetKey("s")) 
    {
        Player.AddForce(0, 0, -4);
    }

    if (Input.GetKeyDown(KeyCode.Space) && isGrounded){

         rb.AddForce(jump * jumpForce, ForceMode.Impulse);
         isGrounded = false;
}

}
}

Hey,

Your almost got it, the weird part about your code is that you have 2 Rigidbodies: Player and rb.

If this script is attached to the player GameObject, just remove the Player Rigidbody variable and replace it in Update() with rb. Like this:

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

[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour
{
    public Camera Camera;
    public Vector3 jump;
    public float jumpForce = 2.0f;

    public bool isGrounded;
    Rigidbody rb;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
        jump = new Vector3(0.0f, 2.0f, 0.0f);
        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Locked;
    }

    void OnCollisionStay()
    {
        isGrounded = true;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey("d"))
        {
            rb.AddForce(4, 0, 0);
        }
        if (Input.GetKey("a"))
        {
            rb.AddForce(-4, 0, 0);
        }
        if (Input.GetKey("w"))
        {
            rb.AddForce(0, 0, 4);
        }
        if (Input.GetKey("s"))
        {
            rb.AddForce(0, 0, -4);
        }
        if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
        {
            rb.AddForce(jump * jumpForce, ForceMode.Impulse);
            isGrounded = false;
        }
    }
}

If your player rotates towards the direction you’re looking at already, just AddForce in the transform.forward direction of your player.