"Outside the bounds of the array"

Does anyone know why these two lines (line 138 in first pic and line 71 in the second) would be creating an error message that says it’s “outside the bounds of an array”. (dialogueName and chosenAnswer are both strings)

well the short answer is, it will be right.

where do you initialise each of those arrays/lists?

There are 3 things in that line that could be an array: dialogue, message and options. I suggest you to separate the access to each of these objects in 3 variables so you can find out exactly which one is causing this problem.

However, since it did not report an exception for line 133, I guess options must be the source of your problems. Since you’re trying to access element 0 and it does not exist it must be empty.

I suggest using the Debugger to see exactly which arrays have which sizes during execution. It should be easy to see what’s going wrong here.

This video does a good job of showing how to use the Debugger for this (around the 7:00 mark):

It works perfectly fine, I just can’t figure out why it makes an error message.
the arrays come from a scriptable object made for dialogues, so there’s always a number 0 in the options.
The options are just a list of answers, like when an NPC asks a question there’s an array of answers.
I’m pretty sure the for statement is correct so it shouldn’t go outside the bounds of the array no matter how many options I add.
It’s supposed to look through and find how many options there are and activate the correct amount option buttons.