The first thing you need for this is a vector describing the direction you want to face (i.e. from your shoulder to the mouse position). Read up on how vectors work here, if you're unsure.
You can do this by saying local directionVector = (mousePosition - torsoPosition).unit
. I'll leave it up to you to find those two positions (note I substituted torso position for shoulder position; it's close enough).
Now you need the vertical angle of this. Some simple trig will tell you this can be done by doing local angle = math.asin(directionVector.y)
.
Now just set the angle of the shoulder to that, and you're good to go. Psuedo code below:
02 | local torsoPosition, mousePosition; |
04 | local defaultShoulderC 1 ; |
07 | local dir = (mousePosition-torsoPosition).unit |
08 | local angle = math.asin(dir.y); |
10 | shoulder.C 1 = defaultShoulderC 1 * CFrame.Angles(angle, 0 , 0 ); |