Im making a gun system and want to have a camera bob when you walk
When I aim down sights the bob works fine, but when im not it just doesnt work, im very confused by this
Local Script:
if walking == true then
gunbobcf = gunbobcf:Lerp(CFrame.new(
0.016 * math.sin(tick() * 6) * (char.Humanoid.WalkSpeed / 12),
0.024 * math.sin(tick() * 12) * (char.Humanoid.WalkSpeed / 12),
0
),0.1)
else
gunbobcf = gunbobcf:Lerp(CFrame.new(0,0,0),0.1)
end
if aiming == false then
framework.camera.PositionGun(CurrentWeapon,gunbobcf)
framework.camera.UnAimDownSights(CurrentWeapon)
else
framework.camera.AimDownSights(CurrentWeapon,gunbobcf)
end
Main Framework (part of it)
function camera.PositionGun(weapon,customOffsetA)
local coa = customOffsetA or CFrame.new(0,0,0)
if weaponModules:FindFirstChild(weapon.Name) then
local wm = require(weaponModules:WaitForChild(weapon.Name))
weapon:SetPrimaryPartCFrame(
workspace.CurrentCamera.CFrame
*coa
*wm.CameraOffset
)
player.Character.Humanoid.WalkSpeed = wm.HolsterSpeed
end
end
function camera.AimDownSights(weapon,customOffsetB)
if weaponModules:FindFirstChild(weapon.Name) then
local wm = require(weaponModules:WaitForChild(weapon.Name))
weapon:SetPrimaryPartCFrame(
workspace.CurrentCamera.CFrame
*aimcf
*customOffsetB
)
tweenFov(70/wm.Zoom,0.1)
aimcf = aimcf:Lerp(wm.AimOffset,0.1)
player.Character.Humanoid.WalkSpeed = wm.AimingWalkSpeed
end
end
Any help would be appreciated.