Good morning Devforum! I’ll get straight to the point. I have an issue with a script regarding arms pointing towards the mouse when torso rotations are involved. Here’s the script:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()
local torso = char:WaitForChild("Torso")
local root = char:WaitForChild("HumanoidRootPart")
local rightShoulder, leftShoulder, neck = torso:WaitForChild("Right Shoulder"), torso:WaitForChild("Left Shoulder"), torso:WaitForChild("Neck")
game:GetService("RunService").Stepped:Connect(function()
local dir = torso.CFrame:ToObjectSpace(mouse.Origin).LookVector.Unit
local rootLook = root.CFrame.LookVector
local torsoLook = torso.CFrame.LookVector
local angleFix = math.acos(math.clamp(rootLook:Dot(torsoLook),-1,1))
rightShoulder.C0 = CFrame.new(1, 0.5, 0) * CFrame.Angles(0, angleFix, 0) * CFrame.Angles(math.asin(dir.Y), 0, 0) * CFrame.Angles(0, -angleFix, 0) * CFrame.Angles(0, math.pi / 2, 0)
local offset = torso.CFrame * rightShoulder.C0 * (CFrame.new(-0.5, 0.5, 0) * CFrame.Angles(0,
math.pi / 2, 0)):Inverse() * CFrame.new(-3, 0, 0) * (CFrame.new(0.5, 0.5, 0))
leftShoulder.C0 = torso.CFrame:ToObjectSpace(offset) * CFrame.Angles(0, -math.pi / 2, 0)
end)
It works fine, until an animation that moves the torso plays.
As you can see, it moves on the yellow axis, however, I want it to move on the green axis. so if anyone knows how to fix this, I’d be happy. Also please note that the script works well when torso rotations aren’t involved.