I have a code in my client script that moves the arms up and down to the mouse. I’ve been tweaking the values for them for quite a while but the arms move more laggy rather than smooth. I’m wondering if there is a way to improve this code.
Resetting the players arms script:
local function ResetCharMovement()
local Neck = Character:FindFirstChild("Neck", true)
Neck.C0 = CFrame.Angles(math.pi/2, math.pi, 0) + Vector3.new(Neck.C0.X, Neck.C0.Y, Neck.C0.Z)
local Arm = Character:FindFirstChild("Right Shoulder", true)
Arm.C0 = CFrame.Angles(0, math.pi/2, 0) + Vector3.new(Arm.C0.X, Arm.C0.Y, Arm.C0.Z)
local LeftArm = Character:FindFirstChild("Left Shoulder", true)
LeftArm.C0 = CFrame.Angles(0, -math.pi/2, 0) + Vector3.new(LeftArm.C0.X, LeftArm.C0.Y, LeftArm.C0.Z)
end
Moving the arms itself:
local function UpdateCharMovement()
local dir = (Mouse.Hit.p - Character.Head.Position).Unit
local angle = math.acos(dir:Dot(Vector3.new(0, 1, 0))) - math.pi/2
angle = math.min(math.max(- math.pi/5, angle), math.pi/5)
local Neck = Character:FindFirstChild("Neck", true)
Neck.C0 = CFrame.Angles(- angle + math.pi/2, math.pi, 0) + Vector3.new(0, Neck.C0.Y, 0)
local Arm = Character:FindFirstChild("Right Shoulder", true)
Arm.C0 = CFrame.Angles(- angle, math.pi/2 + math.pi/40 + math.pi/32, math.pi/36) + Vector3.new(Arm.C0.X, Arm.C0.Y, Arm.C0.Z)
local LeftArm = Character:FindFirstChild("Left Shoulder", true)
LeftArm.C0 = CFrame.Angles(- angle, -math.pi/2 - math.pi/40, -math.pi/36) + Vector3.new(LeftArm.C0.X, LeftArm.C0.Y, LeftArm.C0.Z)
end
Thanks!