---Camera

function Camera()
	local cam=workspace.CurrentCamera
	local CRot=0
	local CBack=0
	local CUp=0
	local look=0
	local camChange = 0
	local function CamUpdate()
		if not pcall (function()
			camChange=DPadUp
			if GMode==2 then
				if math.abs(RStickX)>.1 then
					local sPos=1
					if RStickX<0 then sPos=-1 end
					CRot=sPos*math.abs(((math.abs(RStickX)-.1)/(.9)))*-60
				else
					CRot=0
				end
				if math.abs(RStickY)>.1 then
					local sPos=1
					if RStickY<0 then sPos=-1 end
					CUp=math.min(sPos*math.abs(((math.abs(RStickY)-.1)/(.9)))*-75,30)
				else
					CUp=0
				end
			else
				if CRot>look then
					CRot=math.max(look,CRot-20)
				elseif CRot<look then
					CRot=math.min(look,CRot+20)
				end
				CUp=0
			end
			CBack=-180*ButtonR3
			cam.CameraSubject=car.DriveSeat
			cam.FieldOfView=70
			if GMode==0 then
				cam.CameraType=Enum.CameraType.Custom
				player.CameraMaxZoomDistance=400
			else
				cam.CameraType = "Scriptable"
				local pspeed = math.min(1,car.DriveSeat.Velocity.Magnitude/500)
				local cc = car.DriveSeat.Position+Vector3.new(0,8+(pspeed*2),0)-((car.DriveSeat.CFrame*CFrame.Angles(math.rad(CUp),math.rad(CRot+CBack),0)).lookVector*17)+(car.DriveSeat.Velocity.Unit*-7*pspeed)
				cam.CoordinateFrame = CFrame.new(cc,car.DriveSeat.Position)
			end
		end) then
			cam.FieldOfView=70
			cam.CameraSubject=player.Character.Humanoid
			cam.CameraType=Enum.CameraType.Custom
			player.CameraMaxZoomDistance=400
			run:UnbindFromRenderStep("CamUpdate")
		end
	end
	mouse.KeyDown:connect(function(key)
		if key=="z" then
			look=50
		elseif key=="x" then
			look=-180
		elseif key=="c" then
			look=-50
		end
	end)
	mouse.KeyUp:connect(function(key)
		if key=="z" and look==50 then
			look=0
		elseif key=="x" and (look==-160 or look==-180) then
			look=0
		elseif key=="c" and look==-50 then
			look=0
		end
	end)
	--run:BindToRenderStep("CamUpdate",Enum.RenderPriority.Camera.Value,CamUpdate)
	--table.insert(Binded,"CamUpdate")
	table.insert(Binded,CamUpdate)
end
Camera()