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

FPS Arms. How do I do this?

Asked by 9 years ago

So I'm on my way to making a gun. But wait, the guns arms in first person do not look up with the mouse/head. What do I do? Examples are extremely helpful. Below is the weld arm script that I am using. This is my friend's weld arm and it seems a bit messy, so if I need to remake it I will. I have been wanting to know how to do this for the longest time.

Tool = script.Parent
local User
arms = false
player = game.Players.LocalPlayer
repeat wait() until player.Character
save = player.Character.Torso["Left Shoulder"]:Clone()
Tool.Equipped:connect(function()
    User = Tool.Parent
    if arms == false and player ~= nil then
        User.Torso["Right Shoulder"].C0 = CFrame.new(.6,.2,0) * CFrame.Angles(0,math.rad(90),math.rad(0))
        User.Torso["Left Shoulder"].C0 = CFrame.new(0.1,.2,.7) * CFrame.Angles(0,math.rad(-140),math.rad(-90))
        rarm = player.Character:FindFirstChild("Right Arm"):Clone()
        larm = player.Character:FindFirstChild("Left Arm"):Clone()
        rarm.Parent = game.Workspace.CurrentCamera
        larm.Parent = game.Workspace.CurrentCamera
        rarm.Name = "RA"
        larm.Name = "LA"
        rarm.formFactor = "Custom" 
        larm.formFactor = "Custom"
        larm.Material = "SmoothPlastic"
        rarm.Material = "SmoothPlastic"
        rarm.Size = Vector3.new(0.99,1.99,0.99)
        larm.Size = Vector3.new(0.99,1.99,0.99)
        local weld = Instance.new("ManualWeld",rarm)
        weld.Part0 = player.Character:FindFirstChild("Right Arm")
        weld.Part1 = rarm
        local welda = Instance.new("ManualWeld",larm)
        welda.Part0 = player.Character:FindFirstChild("Left Arm")
        welda.Part1 = larm
        local weldfix = Instance.new("ManualWeld",larm)
        weldfix.Name = "DontTouch"
        weldfix.Part0 = player.Character:FindFirstChild("Left Arm")
        weldfix.Part1 = User.Torso
        weldfix.C0 = CFrame.new(0, 0.6, 0.6)*CFrame.Angles(math.rad(-30),math.rad(0), math.rad(-90))
        arms = true
    end
end)

Tool.Unequipped:connect(function()
    -- Reset actual arms
    if arms == true then
        save.Parent = User.Torso
        User.Torso["Right Shoulder"].C0 = CFrame.new(1,.5,0) * CFrame.Angles(0,math.rad(90),0)
        User.Torso["Left Shoulder"].C0 = CFrame.new(-1,.5,0) * CFrame.Angles(0,math.rad(-90),0)
        save = User.Torso["Left Shoulder"]:Clone()
        larm:Destroy()
        rarm:Destroy()
        arms = false
    end
end)

Answer this question