Part rotates in one axis according to mouse drag

Hello developers!

I would like to make a railways sim on roblox but i have a problem.

I’m struggling to make a part rotate while being grabbed. I cannot really explain what my expectations is so i’ll show you a video instead.

Im not sure if it’s possible to make it work with hinge but that would be the best

Any idea?