Make a GUI rotate when dragged

I am making a plugin where you need to drag a spinner, but instead of moving its position, it will rotate it. So I want it so if I hold down on the frame, and move my mouse right, the frame will start rotating to the right. The Frame will be a circle and I need it to be rotated this way. I have searched the forum for other possible answers but could not find anything. Does anybody know how I could do this?

This will definitely involve trig, I’m typing on phone rn, will explain more on pc.

First you need to make a function that gets the relative rotation of the mouse. Let’s say the mouse is on the left, that would be 270 degrees. If the mouse is up, it would be 0. (rotation might be different with sine)
With the relative x and y values,

local function GetRotation(x, y)
    return math.deg(math.asin(x / y))
end

Then you can set the rotation of the spinner

I am sorry but this confuses me, mind explaining it more? And in that function would that be the x and y of the mouse?