error

Hi All,
I’m trying to create text boxes and the script tells me that there is an error in the update with the last line, but there is no error, can someone tell me why it doesn’t work?, this is the code:
Thanks.

private void Update ()
{
if (text != null)
{
time -= Time.deltaTime;
if (time <= 0f)
{
time += timeCharacter;
characterIx++;
text.text = textWrite.Substring(0, characterIx);
}
}
}

You probably want to change the last line to this…

if (characterIx <= textWrite.Length) text.text = textWrite.Substring(0, characterIx);
1 Like

Please use code-tags (you can easily find them in the editing toolbar) so code shows as in the previous post. Also, for general scripting issues, please post in the scripting forum; this is the 2D feature forum.

Thanks and good luck.

Thanks for your reply, I’ll try it.

1 Like