RS.Heartbeat:Connect(function()if Mode==1 then if UIS.MouseBehavior~=Enum.MouseBehavior.Default and Camera.CameraType~=Enum.CameraType.Custom then UIS.MouseBehavior=Enum.MouseBehavior.Default Camera.CameraType=Enum.CameraType.Custom end elseif Mode==2 then UIS.MouseBehavior=Enum.MouseBehavior.LockCenter Camera.CameraType=Enum.CameraType.Scriptable local L=UIS:GetMouseDelta()local c=Look.X-L.Y*Sensitivity Look=Vector2.new(c>=MaxLook and MaxLook or c<=-MaxLook and-MaxLook or c,(Look.Y-L.X*Sensitivity)%360)Camera.CFrame=(CFrame.new(HRP.Position+CamOffset)*CFrame.Angles(0,math.rad(Look.Y),0))*CFrame.Angles(math.rad(Look.X),0,0)elseif Mode==3 then UIS.MouseBehavior=Enum.MouseBehavior.Default Camera.CameraType=Enum.CameraType.Scriptable Camera.CFrame=(CFrame.new(HRP.Position+CamOffset)*CFrame.Angles(0,math.rad(Look.Y),0))*CFrame.Angles(math.rad(Look.X),0,0)end end)SetSettings.OnClientEvent:Connect(function(L)if L then HidePlayer()Mode=2 else ShowPlayer()Mode=1 end end)UIS.InputBegan:Connect(function(L)if L.KeyCode==FPSLock then if Mode==2 then Mode=3 elseif Mode==3 then Mode=2 end end end)Player.CharacterAdded:Connect(CharacterRespawn)

RS.Heartbeat:Connect(function()
	if Mode == 1 then
		if UIS.MouseBehavior ~= Enum.MouseBehavior.Default and Camera.CameraType ~= Enum.CameraType.Custom then
			UIS.MouseBehavior = Enum.MouseBehavior.Default
			Camera.CameraType = Enum.CameraType.Custom
		end
	elseif Mode == 2 then
		UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
		Camera.CameraType = Enum.CameraType.Scriptable
		local LookDelta = UIS:GetMouseDelta()
		local X = Look.X - LookDelta.Y*Sensitivity
		Look = Vector2.new((X >= MaxLook and MaxLook) or (X <= -MaxLook and -MaxLook) or X,
			(Look.Y - LookDelta.X*Sensitivity) % 360)
		
		Camera.CFrame = CFrame.new(HRP.Position + CamOffset)
			* CFrame.Angles(0,math.rad(Look.Y),0)
			* CFrame.Angles(math.rad(Look.X),0,0)
	elseif Mode == 3 then
		UIS.MouseBehavior = Enum.MouseBehavior.Default
		Camera.CameraType = Enum.CameraType.Scriptable

		Camera.CFrame = CFrame.new(HRP.Position + CamOffset)
			* CFrame.Angles(0,math.rad(Look.Y),0)
			* CFrame.Angles(math.rad(Look.X),0,0)
	end
end)

SetSettings.OnClientEvent:Connect(function(camMode)
	if camMode then
		HidePlayer()
		Mode = 2
	else
		ShowPlayer()
		Mode = 1
	end
end)

UIS.InputBegan:Connect(function(input)
	--Swap Between First and Third Person and Lock the Mouse
	if input.KeyCode == FPSLock then
		if Mode == 2 then Mode = 3
		elseif Mode == 3 then Mode = 2 end
	end
end)

Player.CharacterAdded:Connect(CharacterRespawn)
