Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

First Person Arm - Help?

Asked by 8 years ago

Hi there,

Im trying to make first person arms that move where the mouse is pointing (like you see in many FPS games) like this: https://gyazo.com/86b1c3cedb4c6fab32a5e2f3096f7497

Whenever I try, I always end up with a result like this: https://gyazo.com/c5c7625a060c1e130cadc122657f95f3

In mine, the gun result is never pointing in the mouse direction (like you see in the first example), and I was wondering if anyone could help me. Here's my code:

camera.Changed:connect(function()
    local mag = (camera.CoordinateFrame.p - camera.Focus.p).magnitude
        char.Humanoid.CameraOffset = Vector3.new(0, 0, 0)
        local neck = torso:FindFirstChild("Neck")
        local rshoulder = torso:FindFirstChild("Right Shoulder")
        local lshoulder = torso:FindFirstChild("Left Shoulder")
        if neck then
            local baseNeckAngle = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
            local neckAngle = -0.666
            neck.C0 = baseNeckAngle * CFrame.Angles(neckAngle * camera.CoordinateFrame.lookVector.Y, 0, 0)
        end
        if rshoulder then
            local baseArmAngle = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
            rshoulder.C0 = baseArmAngle * CFrame.Angles(0, 0,camera.CoordinateFrame.lookVector.Y)
        end
        if lshoulder then
            local baseArmAngle = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
            lshoulder.C0 = baseArmAngle * CFrame.Angles(0, 0,-camera.CoordinateFrame.lookVector.Y)
        end
end)

Whoever solves this will get a payment of 1-2k R$ (if you want) as I really would like to know how to do this.

Thanks!

0
Rule three of the community guidelines: Do not offer any rewards for answers to your questions. XAXA 1569 — 8y

Answer this question