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 R,k=math.abs,math.cos local t=c.CoordinateFrame.lookVector.Y for R,k in pairs(RIG)do R.C0=k.C0*CFrame.Angles(k.Factor.X*t,k.Factor.Y*t,k.Factor.Z*t)R.C1=k.C1 end rootJ.C0=rootJ.C0*CFrame.new(0,t,0)local u=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 R=(head.CFrame:toObjectSpace(torso.CFrame)).p.magnitude u=root.CFrame:toObjectSpace(head.CFrame)-Vector3.new(0,R-(1+t)/8,.25)else if script.Parent.Parent.PlayerGui.GUI.Asset.Jar.Stamina.Spectation.Running.Value==false then c.FieldOfView=80 end end local n=k(tick()*(math.pi*2.5))local L=CFrame.new((n/3)*waveScale,R(n/5)*waveScale,0)humanoid.CameraOffset=(u*L).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)
