I have an array problem

I’m basically trying to create a sort of a line that will wait for the first triggered before moving on to the next.

If that didn’t make sense, think of an RTS where you can queue your research and spawning on top of each other.

I have hashed together an idea I had using an array but it doesn’t seem to work after the first trigger. Here’s the code:

Okay, couldn’t get the in forum code formatting to work, so here’s a pastebin link

The array just stops working and registers any more strings for a only frame after the first action completes, effectively doing nothing.

Also, if my scripting is bad and makes your head hurt, I apologize, I still consider myself a novice and I’ve been too busy to find and do advanced tutorials. Bear with me.

Also, it seems very cumbersome to do it my way, so if you have any suggestions of other ways, I’m all ears. I can be flexible.

EDIT: I have tried several different setups with queue, every single one runs with no errors but doesn’t work with the if statement. I don’t know if it’s my fault or unity. I have tried: using .Equals(object) inside of an if statement, .Equals(object) as a boolean, .Peek = object inside an if statment.

Jessy is correct, what you need is a Queue. Queue’s work on the FIFO (First In, First Out) principle, so you can keep queueing multiple things up and fetch things one at a time as you’re ready.