--Put it in startercharacterscripts


local runService = game:GetService("RunService")

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local TS = game:GetService("TweenService")

function updateBobbleEffect()
	local currentTime = tick()
	if humanoid.MoveDirection.Magnitude > 0 then -- we are walking
		local bobbleX = math.cos(currentTime * 5.6) * .5
		local bobbleY = math.abs(math.sin(currentTime * 5.6)) * .5

		local bobble = Vector3.new(bobbleX, bobbleY, -.45)
		TS:Create(humanoid, TweenInfo.new(.1), {CameraOffset = humanoid.CameraOffset:lerp(bobble, .35)}):Play()
	else -- we are not walking
		TS:Create(humanoid, TweenInfo.new(.1), {CameraOffset = Vector3.new(0, 0, -.45)}):Play()
	end
end


runService.RenderStepped:Connect(updateBobbleEffect)
