Setting Velocity Zero

Hi so i’m using a script and and I wanna set the velocity to zero and I tried using this - rigidbody.velocity = Vector3.zero; but it just has red underlines and doesnt work. Any help please?

Hi, are you sure you used GetComponent before to get the rigidbody of the GameObject? Use this:

public Rigidbody RB;

void Start()
{
RB = GetComponent<Rigidbody>();
}

void Update()
{
RB.velocity = Vector3.zero;
}