Hi! So, I followed along a camera head bobbing tutorial and it worked pretty well. The bottom line is that I noticed that the camera bobbing kept noticeably skipping to the top (I changed the script so the head bobbing is only bobbing on the Y axis). This is what I meant:
How can I fix this? Here’s the script:
local RunS = game:GetService("RunService")
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local function bob()
if hum.MoveDirection.Magnitude > 0 and hum.Sit == false then
local currentTime = tick()
local bobbleY = math.abs(math.sin(currentTime * 5)) * .5
local bobble = Vector3.new(0, bobbleY, 0)
hum.CameraOffset = hum.CameraOffset:lerp(bobble, 1)
else
hum.CameraOffset = hum.CameraOffset * .75
end
end
RunS.RenderStepped:Connect(bob)