I’m making a gun system that uses the real character’s arms and I’m on the part that does the aiming. Everything is fine except for the fact that the Left Arm just acts weirdly?
Here:
When I’m not moving my camera or anything, it goes to the right spot. However, when I’m moving my camera fast and then I aim in, its position screws up. I also have a feature where pressing “T” moves the angle you aim from, and that also causes the arm to move. I just want the left arm to stay in one place.
Here’s the code.
ads = ads + ((aiming and 1 or 0) - ads) * .05
local part
if sideAim then
part = gun.SideAimCF
else
part = gun.AimCF
end
aimSway = aimSway:Lerp(CFrame.Angles(math.rad(mouseDelta.Y*1),math.rad(mouseDelta.X*3),math.rad((gunRot*1.5)+gunPitch)),.1)
local Offset = script.Parent["Right Arm"].CFrame:ToObjectSpace(part.CFrame) * aimSway
local Aim = torso.CFrame:ToObjectSpace(cam.CFrame * Offset:Inverse()) * rightArm.C1 * rightArm.Transform:Inverse()
local LOffset = script.Parent["Left Arm"].CFrame:ToObjectSpace(part.CFrame) * aimSway
local LAim = torso.CFrame:ToObjectSpace(cam.CFrame * LOffset:Inverse()) * leftArm.C1 * leftArm.Transform:Inverse()
rightArm.C0 = riteaimOrigin:Lerp(Aim, ads)
leftArm.C0 = lefaimOrigin:Lerp(LAim, ads)
--rightArm = Right Shoulder motor, leftArm = Left Shoulder motor. the "aimOrigin" variables get set when the player first aims in to determine where the arms should be before lerping into the aiming position.
oh u used my solution from ur last post, but heres where u went wrong. that offset trick only works on the right arm cause the gun is welded to it so its offset never changes. the left arm isnt attached to anything, so whatever offset it has when u aim in (like if its lagging from moving ur camera fast) just gets locked in
what u need to do instead is give it a fixed spot on the gun and place it from where the right arm actually is:
LeftGrip is just a fixed CFrame for where the left arm sits relative to the Wood part. easiest way to get it is pose the left arm how u want it on ur StarterCharacter and run this in the command bar, then paste the result in as a constant:
local c = game.StarterPlayer.StarterCharacter
print(c["AK-47"].Wood.CFrame:ToObjectSpace(c["Left Arm"].CFrame))
u dont need LOffset or the left lerp anymore since it just follows the gun
wait so where would this code even go? and wouldn’t this forcibly attach the left arm to a part of the gun (ie. “Wood” which not all guns will have)? i just want it to be the same distance apart relative to how it is when the player isn’t aiming