unity c# - IndexOutOfRangeException

So I made a little game that has a problem. As soon as I load the game, I get errors. Lots of them.

I can’t seem to find the problem in this code:

//This is where the exception is
Touch touch = Input.touches [0];

float TouchTime;

		if (touch.phase == TouchPhase.Began) {
			TouchTime = Time.time;

		if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) {
			if (Time.time - TouchTime <= 0.5) {
				//response to tap
				print ("");

			else {
				print ("Long press was" + TouchTime + "seconds long.");

Also this was in the update() method, which might explain the huge number of errors, but how do I fix this?

Are you always touching the screen? If not, there won’t be any touches in the Input.touches array, so attempting to access Input.touches[0] will produce the exception described.