How to move one object with right mouse button?

Hello Everyone,

How I can assign my right button mouse to this script? I want to press my right mouse button and move my object.

This is the original script.

Please any advice is more than welcome!

var movedownY = 0.0;
var sensitivityY = 0.1;

function Update(){
                                                                                                         
movedownY += Input.GetAxis("Mouse Y") * sensitivityY;
if (Input.GetAxis("Mouse Y") != 0){
transform.Translate(Vector3.forward * movedownY);
}
movedownY = 0.0;
}

If the above script works as intended, but you want to add another condition where the user must be clicking the right mouse button, then try this:

    var movedownY = 0.0;
    var sensitivityY = 0.1;
     
    function Update() {
		if (Input.GetAxis("Mouse Y") != 0 && Input.GetButton("Fire2")) {
			movedownY += Input.GetAxis("Mouse Y") * sensitivityY;
			transform.Translate(Vector3.forward * movedownY);
		}
		movedownY = 0.0;
    }

NOTE: This is assuming you have the input “Fire2” mapped to your right mouse button!