How do I move my tool with my arms when it is not connected with a handle?

I have started work on a gun system and I wanted my arms and gun to follow the mouse going up and down on the y axis in first person. I have gotten the arms to go up and down thanks to a tutorial and I was able to adjust it to my needs. However when I tried it, the gun would not move with the arms. I’ve tried connecting it to the handle which works but also breaks my animation(I use a motor6d animation that connects to the torso, I have tried moving it to the right arm but it does not work). I have also tried welding the BasePart of my gun to the right arm but the right arm ends up being stuck with the gun.

:Example(The time I tried to weld it to the right arm.

https://vimeo.com/940479265?share=copy

:Code(Uses the code I used to weld the right arm and move the arms)

wait()

local player = game.Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
end
local humanoid = character:WaitForChild(“Humanoid”)
local torso = character:WaitForChild(“Torso”)
local rightShoulder = torso:WaitForChild(“Right Shoulder”)
local leftShoulder = torso:WaitForChild(“Left Shoulder”)
local head = character:WaitForChild(“Head”)
local rootpart = character:WaitForChild(“HumanoidRootPart”)
local camera = game.Workspace.CurrentCamera
local bodyattach = character:WaitForChild(“Tool”)
local toolequpped = false

updateSpeed = 0.5/2
bodyattach.Equipped:Connect(function()
toolequpped = true
end)
bodyattach.Unequipped:Connect(function()
toolequpped = false
end)
local newweld = Instance.new(“Weld”)
newweld.Parent = character[“Right Arm”]
newweld.Part0 = bodyattach.BodyAttach
newweld.Part1 = character[“Right Arm”]

game:GetService(“RunService”).RenderStepped:Connect(function()
character[“Right Arm”].LocalTransparencyModifier = character[“Right Arm”].Transparency
character[“Left Arm”].LocalTransparencyModifier = character[“Left Arm”].Transparency
local camCF = camera.CoordinateFrame
local distance = (character.Head.Position - camCF.p).magnitude
if distance <= 2 and humanoid.Health ~= 0 then
rightShoulder.C0 = rightShoulder.C0:lerp((camCF * CFrame.new(1, -1, -.5)):toObjectSpace(torso.CFrame):inverse() * CFrame.Angles(0, math.pi/2, 0), updateSpeed)
leftShoulder.C0 = leftShoulder.C0:lerp((camCF * CFrame.new(-1, -1, -.5)):toObjectSpace(torso.CFrame):inverse() * CFrame.Angles(0, -math.pi/2, 0), updateSpeed)
humanoid.CameraOffset = (rootpart.CFrame+Vector3.new(0,1.5,0)):pointToObjectSpace(head.CFrame.p)
else
rightShoulder.C0 = CFrame.new(1, 0.5, 0) * CFrame.Angles(0, math.pi/2, 0)
leftShoulder.C0 = CFrame.new(-1, 0.5, 0) * CFrame.Angles(0, -math.pi/2, 0)
humanoid.CameraOffset = Vector3.new(0,0,0)
end
end)

My question is, is there any practical way I can move this gun with my arms without using a handle. If their isn’t what should I do to try and make what I wanted?

1 Like