Currently trying to make ADS, it works fine when the model isn't rotated, but as soon as it rotates at all the point where it aims offsets from where the aim part is.
Code for aiming:
-- Aiming
local aimPart = gunModel:FindFirstChild("AimPart"..sightIndex) or gunModel.AimPart
aimTarget = aimPart.CFrame:ToObjectSpace(camera.CFrame)
if aiming then
aimingOffset = aimingOffset:Lerp(aimTarget,(0.7 / equipped:FindFirstChild("ActiveStats").AimSpeed.Value) * 0.3 * dt * 60)
else
aimingOffset = aimingOffset:Lerp(CFrame.new(),(0.7 / equipped:FindFirstChild("ActiveStats").AimSpeed.Value) * 0.3 * dt * 60)
end
animBase.CFrame *= aimingOffset
Code for the rotation: (This isn't directly after the aiming code in the full script)
local angle = math.rad(15*-lean)
local rotation = CFrame.Angles(0, 0, angle)
animBase.CFrame *= rotation