So i'm trying to get an angle from 2 vectors (one of them is the mouse.hit position, the other is the player's right hand), but im having this issue where the angle changes based off of the distance between the 2 vectors. For example if im looking forwards at a part that is 10 studs infront of me it might say an angle of 2 but if i walk to the side without even moving my mouse but the mouse is no longer hitting that part and is instead hitting a part say 100 studs away it would change to an angle of 50 eventhough the distance between the 2 vectors should not be affecting the angle in any way.
This is the math:
math.deg(math.acos(RightHand.Position:Dot(Mouse.Hit.Position)/(RightHand.Position.Magnitude * Mouse.Hit.Position.Magnitude)))
As stated in a comment, you want the arm to point where the mouse goes. Here is the script that I use, but without remote-events and it misses alot of the necessary variables. I'll explain what you need and the problems with the script, but I don't have Studio right now so I can't confirm anything.
local Shoulder = Character.Torso["Right Shoulder"] local ShoulderOffset = CFrame.new() local Mouse = Player:GetMouse() game:GetService("RunService").RenderStepped:Connect(function() local MouseLookVector = Mouse.LookVector Shoulder.C0 = ShoulderOffset * CFrame.Angles(0,0,0) * CFrame.Angles(-math.asin(MouseLookVector.Y),0,0) end)
ShoulderOffset isn't actually a blank CFrame. You can get the actual offset by printing the C0 of the RightShoulder Motor6D in a Dummy. You'll need to use the command bar for this.
I haven't defined Player, Character so you'll need to do those.
In the first CFrame.Angles. One of the values will be pi/2 or 90 degrees because otherwise the arm won't be pointing straight at the mouse and I forget which axis it needs to be offset on. Similarly, it is possible that the X axis isn't the proper axis to rotate the arm on, in which case you can try switching it to the Y or Z axis. It's also possible that there shouldn't be a minus because otherwise the arm will move opposite the mouse (pointing up will move the arm down); interesting thing to note is that if the right arm has a negative arcsin then the left arm will have a positive one.
This won't replicate to the server, you'll need remote events for those.
There won't be a way to stop this you will have to script it yourself but it should be easy.