How to make a free rotate part system

So I want whenever the player holds down the right click and moves their mouse the brick will rotate depending on how they move their mouse how can I do this I just need to know how to update the parts orientation based on the mouse position and the way they move their mouse I have everything else made.