[ Sorry for late response, was in the middle of a WarThunder match with a friend ]
Hey thanks for pointing out a typo, you really got me there hahahahaha…
As for why it looks detached, its because the arm is being rotated in un-natural positions, and since this is r6, there is no upper right arm to compensate for the un-natural poses and make it looks slighly more realistic.
Though here i’ve attempted to make it slighly better, by clamping the angle so that it cant look behind the character, and using a new method to get the plane cframe, which might fix issues where the arm angle isn’t correct.
The correct approach to here to have no weird detachment, or un-natural bending, I believe would be a 2 joint system, with inverse kinematics to set the joints.
Here is my updated code for you
local mou = game.Players.LocalPlayer:GetMouse()
local f = false
local og = script.Parent.Torso["Right Shoulder"].C0
local shoulderSize = script.Parent.Torso["Right Shoulder"].Part1.Size
local fixedRS = script.Parent.Torso["Right Shoulder"].Part1.CFrame + Vector3.new(0,shoulderSize.Y/2,0)
local cOffset = script.Parent.Torso.CFrame:ToObjectSpace(fixedRS)
local forwardV3 = Vector3.new(0,0,-1)
game:GetService("RunService").RenderStepped:Connect(function()
local cf = script.Parent.Torso.CFrame * cOffset
local hit = mou.Hit.p
local localized = cf:PointToObjectSpace(hit)
local localizedUnit = localized.Unit
local axis = forwardV3:Cross(localizedUnit)
local angle = math.clamp(math.acos(-localizedUnit.Z),-math.pi/2,math.pi/2)
local planeCf = cf * CFrame.fromAxisAngle(axis,angle)
local look = script.Parent.Torso["Right Shoulder"].Part1.CFrame.LookVector
local relative = script.Parent.Torso["Right Shoulder"].Part1.Position - hit
local dot = look:Dot(relative.unit)
local cAngle = CFrame.Angles(math.acos(dot),0,0)
script.Parent.Torso["Right Shoulder"].C0 = script.Parent.Torso.CFrame:ToObjectSpace(planeCf) * cAngle
end)
PS: Please don’t start whining because you may have not got exactly what you wanted.
Perhaps someone else, who knows more than me can help you better, though I think we’ve reached the limit of what an r6 model can do naturally. This is my final post here, cheers and please do…
touch some grass