humanoid.StateChanged:Connect(function(T,Y)if isfirstperson==true and includejumpsway==true then if Y==Enum.HumanoidStateType.Landed then local T=Instance.new("\067\070\114\097\109\101\086\097\108\117\101")T.Value=CFrame.new(0,0,0)*CFrame.Angles(math.rad(-0.75)*swaysize,0,0)local Y=tweenservice:Create(T,TweenInfo.new(.18/sensitivity,Enum.EasingStyle.Linear,Enum.EasingDirection.Out),{Value=CFrame.new(0,0,0)})Y:Play();(game:GetService("\068\101\098\114\105\115")):AddItem(Y,2)Y.Completed:Connect(function()T.Value=CFrame.new(0,0,0)*CFrame.Angles(math.rad(.225)*swaysize,0,0)local Y=tweenservice:Create(T,TweenInfo.new(.72/sensitivity,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Value=CFrame.new(0,0,0)})Y:Play();(game:GetService("\068\101\098\114\105\115")):AddItem(Y,3)end)spawn(function()for Y=1,60,1 do camera.CFrame=camera.CFrame*T.Value runservice.Heartbeat:Wait()end end)local J=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)})J:Play();(game:GetService("\068\101\098\114\105\115")):AddItem(J,2)J.Completed:Connect(function()local T=tweenservice:Create(jumpswaygoal,TweenInfo.new(.7/sensitivity,Enum.EasingStyle.Quart,Enum.EasingDirection.Out),{Value=CFrame.new(0,0,0)})T:Play();(game:GetService("\068\101\098\114\105\115")):AddItem(T,2)end)elseif Y==Enum.HumanoidStateType.Freefall then local T=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)})T:Play();(game:GetService("\068\101\098\114\105\115")):AddItem(T,2)end end end)

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