My spaceship does not move forward when mouse is pressed down

To summarize what I want it to do: I am trying to code it so that when one button is pressed, the player’s ship will start moving forward in the direction that it is facing. If a different button is pressed, the player’s ship will start moving backward from the direction that it is facing.
I starting coding it with rigidbody2d, but it doesn’t move forward or backwards when I press them down. Tried many times to fix it, to figure out where I am going wrong, but I cannot find out what code is being problematic.
Here is the code right now:

public class SpaceShip : MonoBehaviour
{
    public float acceleration;
    private Rigidbody2D rb2d;

    private Vector2 forward;

    void Start()
    {
        rb2d = GetComponent<Rigidbody2D>();
    }

    private void FixedUpdate()
    {
        forward = transform.position + transform.forward;
        if (Input.GetMouseButton(0))
        {
            rb2d.AddForce(forward * acceleration);
        }
        else if (Input.GetMouseButton(1))
        {
            rb2d.AddForce(-forward * acceleration);
        }
    }

Do you set the acceleration value anywhere? If that’s not set (or 0 for that matter), the AddForce function won’t have anything to add.

When you debug, does it reach the AddForce line? If so, what value does the (forward * acceleration) have?

Ran your script. Set acceleration to 100 in Editor.
Added a Debug.Log() that showed your forward calc was always 0.0. You also didn’t specify the ForceMode2D mode. Don’t know what the default is if you don’t have it.

            Debug.Log("LMB " + forward);
//            rb2d.AddForce(forward * acceleration, ForceMode2D.Force);
            rb2d.AddForce(Vector3.up, ForceMode2D.Force);

seemed to work for moving upwards.

I think CmdrZin solved your problem but I can’t help but notice you are replacing the transform.forward vector with a vector that is dependent on position. This means it will move differently based on where it is in the map and since that vector is not normalized it will move faster as it gets farther from 0, 0. I think you just want to use transform.forward instead of forward.