Can't figure out why I'm getting this error "Cannot use 'velocity' on a static body. UnityEngine.Rigidbody2D:set _velocity(Vector2)".

The rigidbody2D bodytype is set to dynamic so I don’t understand why I’m getting the error. Essentially I want my gameobject to stop dead when I release the directional buttons. Thanks in advance for any help. Here’s my script.

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

public class PlayerController : MonoBehaviour
{
public float speed;

private Rigidbody2D rb2d;

private void Start()
{
    rb2d = GetComponent<Rigidbody2D>();
    
}
private void FixedUpdate()
{
    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");
    Vector2 movement = new Vector2(moveHorizontal, moveVertical);
    rb2d.AddForce(movement * speed);
    rb2d.velocity = Vector2.zero;
}

}

Try something like this :

private void FixedUpdate()
{
    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");
    if (Mathf.Approximately(0,  moveHorizontal + moveVertical))
    {
         rb2d.velocity = Vector2.zero;
    }
    else
    {
         Vector2 movement = new Vector2(moveHorizontal, moveVertical);
         rb2d.AddForce(movement * speed);
    }
 }

Check if you have checked the static bool in inspector
@Stuart_of_London