humanoid.StateChanged:Connect(function(m,M)if isfirstperson==true and includejumpsway==true then if M==Enum.HumanoidStateType.Landed then local m=Instance.new("\067\070\114\097\109\101\086\097\108\117\101")m.Value=CFrame.new(0,0,0)*CFrame.Angles(math.rad(-0.75)*swaysize,0,0)local M=tweenservice:Create(m,TweenInfo.new(.18/sensitivity,Enum.EasingStyle.Linear,Enum.EasingDirection.Out),{Value=CFrame.new(0,0,0)})M:Play();(game:GetService("\068\101\098\114\105\115")):AddItem(M,2)M.Completed:Connect(function()m.Value=CFrame.new(0,0,0)*CFrame.Angles(math.rad(.225)*swaysize,0,0)local M=tweenservice:Create(m,TweenInfo.new(.72/sensitivity,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Value=CFrame.new(0,0,0)})M:Play();(game:GetService("\068\101\098\114\105\115")):AddItem(M,3)end)task.spawn(function()for M=1,60,1 do camera.CFrame=camera.CFrame*m.Value runservice.Heartbeat:Wait()end end)local C=tweenservice:Create(jumpswaygoal,TweenInfo.new(.15/sensitivity,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Value=CFrame.new(0,0,0)*CFrame.Angles(-math.rad(5)*swaysize,0,0)})C:Play();(game:GetService("\068\101\098\114\105\115")):AddItem(C,2)C.Completed:Connect(function()local m=tweenservice:Create(jumpswaygoal,TweenInfo.new(.7/sensitivity,Enum.EasingStyle.Quart,Enum.EasingDirection.Out),{Value=CFrame.new(0,0,0)})m:Play();(game:GetService("\068\101\098\114\105\115")):AddItem(m,2)end)elseif M==Enum.HumanoidStateType.Freefall then local m=tweenservice:Create(jumpswaygoal,TweenInfo.new(.5/sensitivity,Enum.EasingStyle.Sine),{Value=CFrame.new(0,0,0)*CFrame.Angles(math.rad(7.5)*swaysize,0,0)})m:Play();(game:GetService("\068\101\098\114\105\115")):AddItem(m,2)end end end)
-- listen for jumping and landing and apply sway and camera mvoement to the viewmodel
humanoid.StateChanged:Connect(function(oldstate, newstate)
	if isfirstperson == true and includejumpsway == true then -- dont apply camera/viewmodel changes if we aren't in first person
		if newstate == Enum.HumanoidStateType.Landed then
			-- animate the camera's landing "thump"
			--
			-- tween a dummy cframe value for camera recoil
			local camedit = Instance.new("CFrameValue")
			camedit.Value = CFrame.new(0, 0, 0) * CFrame.Angles(math.rad(-0.75) * swaysize, 0, 0)
			local landedrecoil = tweenservice:Create(
				camedit,
				TweenInfo.new((0.03 * 6) / sensitivity, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),
				{ Value = CFrame.new(0, 0, 0) }
			)
			landedrecoil:Play()
			game:GetService("Debris"):AddItem(landedrecoil, 2)
			landedrecoil.Completed:Connect(function()
				camedit.Value = CFrame.new(0, 0, 0) * CFrame.Angles(math.rad(0.225) * swaysize, 0, 0)
				local landedrecovery = tweenservice:Create(
					camedit,
					TweenInfo.new((0.03 * 24) / sensitivity, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{ Value = CFrame.new(0, 0, 0) }
				)
				landedrecovery:Play()
				game:GetService("Debris"):AddItem(landedrecovery, 3)
			end)
			-- apply the camera adjustments
			task.spawn(function()
				for i = 1, 60 do
					camera.CFrame = camera.CFrame * camedit.Value
					runservice.Heartbeat:Wait()
				end
			end)
			-- animate the jump sway to make the viewmodel thump down on landing
			local viewmodelrecoil = tweenservice:Create(
				jumpswaygoal,
				TweenInfo.new(0.15 / sensitivity, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
				{ Value = CFrame.new(0, 0, 0) * CFrame.Angles(-math.rad(5) * swaysize, 0, 0) }
			)
			viewmodelrecoil:Play()
			game:GetService("Debris"):AddItem(viewmodelrecoil, 2)
			viewmodelrecoil.Completed:Connect(function()
				local viewmodelrecovery = tweenservice:Create(
					jumpswaygoal,
					TweenInfo.new(0.7 / sensitivity, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),
					{ Value = CFrame.new(0, 0, 0) }
				)
				viewmodelrecovery:Play()
				game:GetService("Debris"):AddItem(viewmodelrecovery, 2)
			end)
		elseif newstate == Enum.HumanoidStateType.Freefall then
			-- animate jump sway when the character is falling or jumping
			local viewmodeljump = tweenservice:Create(
				jumpswaygoal,
				TweenInfo.new(0.5 / sensitivity, Enum.EasingStyle.Sine),
				{ Value = CFrame.new(0, 0, 0) * CFrame.Angles(math.rad(7.5) * swaysize, 0, 0) }
			)
			viewmodeljump:Play()
			game:GetService("Debris"):AddItem(viewmodeljump, 2)
		end
	end
end)
