Okay so I made a musket/gun which I am relatively proud of. However I am currently wanting the gun to move with the arms when aiming. As you can see in the video below, the musket doesn’t follow the arms. I was just wondering how I’d script it so the gun moves with it. Everything is connected to one part in the tool called “BodyAttach” via Motor6D’s.
Here is the script in StarterPlayerScripts that when the player is aiming, is enabled. I am using a script I found on the dev forum and I’m not sure how to edit in the tool.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait() ; Character = Player.Character
local Torso = Character:WaitForChild'Torso'
local Neck = Torso:WaitForChild("Neck")
local LeftShoulder = Torso:WaitForChild("Left Shoulder")
local RightShoulder = Torso:WaitForChild("Right Shoulder")
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.AutoRotate = false
local HMR = Character:WaitForChild("HumanoidRootPart")
local Mouse = Player:GetMouse()
local RC0 = CFrame.new(1, .5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
local RC1 = CFrame.new(-.5, .5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
local LC0 = CFrame.new(-1, .5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
local LC1 = CFrame.new(.5, .5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
local NeckC0 = Neck.C0
local NeckC1 = Neck.C1
game:GetService("RunService").RenderStepped:connect(function()
local cf = workspace.CurrentCamera.CFrame.lookVector.Y
local Kek = CFrame.Angles(0, 0, math.asin(Mouse.Origin.lookVector.Y))
RightShoulder.C1 = RC1 * Kek:Inverse()
LeftShoulder.C1 = LC1 * Kek
Neck.C0 = NeckC0 * CFrame.Angles(math.asin(Mouse.Origin.lookVector.Y), 0, 0):inverse()
HMR.CFrame = CFrame.new(HMR.Position, Vector3.new(Mouse.Hit.p.x, HMR.Position.Y, Mouse.Hit.p.z))
end)