Need help fixing a camera head bobbing script

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)
1 Like

Did you try changing the 1?

Also, you should just increase the time by the speed the human is running, not tick.

I feel dumb for not using a variable and changing that variable by the desired amount. Thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.