I think its because since the Touches are stored in an array, you have to iterate through it (like they have shown in the documentations) according to the touchCounts registered. If not, like Wolfram mentioned, you will be accessing the first element of an empty array.
I can fix this problem by add condition: if(Input.touchCount > 0)
I put my code in Update() function so at the beginning, when i have no touch, this code still run, i think the problem is come from there
// Return X or Y Coord of touch - Use Ex: ToqueCoord ('x', i); i as index of touch;
int ToqueCoord(char c, int i) {
int x = 0, y = 0;
int t = Input.touches.GetLength (0);
Debug.Log (t);
if (t >= (i)) {
x = (int)Input.touches [i - 1].position.x;
y = (int)Input.touches [i - 1].position.y;
Debug.Log ("OK");
}
if (c == 'x') {
return (x);
}
if (c == 'y') {
return (y);
}
return (0);
}