rs.RenderStepped:connect(function()if active then if waveScale<.5 then waveScale=math.min(.5,waveScale+scaleIncrement)end else if waveScale>0 then waveScale=math.max(0,waveScale-scaleIncrement)end end local g,h=math.abs,math.cos local l=c.CoordinateFrame.lookVector.Y for g,h in pairs(RIG)do g.C0=h.C0*CFrame.Angles(h.Factor.X*l,h.Factor.Y*l,h.Factor.Z*l)g.C1=h.C1 end rootJ.C0=rootJ.C0*CFrame.new(0,l,0)local V=CFrame.new()if(c.Focus.p-c.CoordinateFrame.p).magnitude<1 then if script.Parent.Parent.PlayerGui.GUI.Asset.Jar.Stamina.Spectation.Running.Value==false then c.FieldOfView=100 end local g=(head.CFrame:toObjectSpace(torso.CFrame)).p.magnitude V=root.CFrame:toObjectSpace(head.CFrame)-Vector3.new(0,g-(1+l)/8,.25)else if script.Parent.Parent.PlayerGui.GUI.Asset.Jar.Stamina.Spectation.Running.Value==false then c.FieldOfView=80 end end local G=h(tick()*(math.pi*2.5))local d=CFrame.new((G/3)*waveScale,g(G/5)*waveScale,0)humanoid.CameraOffset=(V*d).p end)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

rs.RenderStepped:connect(function()
	if active then
		if waveScale < 0.5 then
			waveScale = math.min(0.5, waveScale + scaleIncrement)
		end
	else
		if waveScale > 0 then
			waveScale = math.max(0, waveScale - scaleIncrement)
		end
	end
	local abs, cos = math.abs, math.cos
	local camY = c.CoordinateFrame.lookVector.Y
	for joint, def in pairs(RIG) do
		joint.C0 = def.C0 * CFrame.Angles(def.Factor.X * camY, def.Factor.Y * camY, def.Factor.Z * camY)
		joint.C1 = def.C1
	end
	rootJ.C0 = rootJ.C0 * CFrame.new(0, camY, 0) -- Painful fix, but the player glides forward and backwards a bit when looking up and down without this.
	local headOffset = CFrame.new()
	if (c.Focus.p - c.CoordinateFrame.p).magnitude < 1 then
		if script.Parent.Parent.PlayerGui.GUI.Asset.Jar.Stamina.Spectation.Running.Value == false then
			c.FieldOfView = 100
		end
		local dist = head.CFrame:toObjectSpace(torso.CFrame).p.magnitude
		headOffset = root.CFrame:toObjectSpace(head.CFrame) - Vector3.new(0, dist - ((1 + camY) / 8), 0.25)
	else
		if script.Parent.Parent.PlayerGui.GUI.Asset.Jar.Stamina.Spectation.Running.Value == false then
			c.FieldOfView = 80
		end
	end
	local t = cos(tick() * (math.pi * 2.5))
	local bobble = CFrame.new((t / 3) * waveScale, abs(t / 5) * waveScale, 0) -- Makes the view move side to side. The wave scale is tweened between 0 and 1 depending on if the player is walking or not.
	humanoid.CameraOffset = (headOffset * bobble).p
end)
