I have this code for typing and displaying it on a guitext, but the backspace isn’t working.

When the keypad “.” is pressed the backspace works although the keypad numbers won’t work anymore.

```
/
/
void Start()
{
CPURead.guiText.text = "0000";
}
void Update ()
{
if(Input.GetKeyDown(KeyCode.KeypadPeriod))
{
if (guiText.text.Length >= min_MaxDigits)
{
guiText.text = guiText.text.Substring(0, guiText.text.Length - 1);
}
else
{
}
}
if(Input.GetKeyDown(KeyCode.Keypad1))
{
if (m_Digits.Length < m_MaxDigits)
{
m_Digits = m_Digits + "1";
CPURead.guiText.text = m_Digits;
}
}
if(Input.GetKeyDown(KeyCode.Keypad2))
{
if (m_Digits.Length < m_MaxDigits)
{
m_Digits = m_Digits + "2";
CPURead.guiText.text = m_Digits;
}
}
if(Input.GetKeyDown(KeyCode.Keypad3))
{
if (m_Digits.Length < m_MaxDigits)
{
m_Digits = m_Digits + "3";
CPURead.guiText.text = m_Digits;
}
}
if(Input.GetKeyDown(KeyCode.Keypad4))
{
if (m_Digits.Length < m_MaxDigits)
{
m_Digits = m_Digits + "4";
CPURead.guiText.text = m_Digits;
}
}
if(Input.GetKeyDown(KeyCode.Keypad5))
{
if (m_Digits.Length < m_MaxDigits)
{
m_Digits = m_Digits + "5";
CPURead.guiText.text = m_Digits;
}
}
if(Input.GetKeyDown(KeyCode.Keypad6))
{
if (m_Digits.Length < m_MaxDigits)
{
m_Digits = m_Digits + "6";
CPURead.guiText.text = m_Digits;
}
}
if(Input.GetKeyDown(KeyCode.Keypad7))
{
if (m_Digits.Length < m_MaxDigits)
{
m_Digits = m_Digits + "7";
CPURead.guiText.text = m_Digits;
}
}
if(Input.GetKeyDown(KeyCode.Keypad8))
{
if (m_Digits.Length < m_MaxDigits)
{
m_Digits = m_Digits + "8";
CPURead.guiText.text = m_Digits;
}
}
if(Input.GetKeyDown(KeyCode.Keypad9))
{
if (m_Digits.Length < m_MaxDigits)
{
m_Digits = m_Digits + "9";
CPURead.guiText.text = m_Digits;
}
}
if(Input.GetKeyDown(KeyCode.Keypad0))
{
if (m_Digits.Length < m_MaxDigits)
{
m_Digits = m_Digits + "0";
CPURead.guiText.text = m_Digits;
}
}
/
/
```

I get this error-

```
/
/
ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
System.String.Substring (Int32 startIndex, Int32 length)
/
/
```