Holding down right mouse click to rotate free camera help

If you know games such as Welcome To Bloxburg and My Prison, they utilize a building system, which let’s the player move around freely with a camera.

I have already made the movement in the camera system, so that when the W, A, S, or D key is hold, the camera moves. I’m only struggling on how to make the camera “follow” the mouse when the right mouse is hold, so it rotate with it.

Any ideas on how I can achieve this?

Bumping this because I’d also like to know how it’s done