Array skips to end?

Hi! I will try to explain this and make it as simple as possible. So, the reason why it is not stopping is because you are using a for loop. A for loop (used with an array, such as your Female hair array) will not stop unless you explicitly tell it to do otherwise. If you use a forloop with break you can tell it to stop basically whenever you want it to. You are not telling it to stop as of now. However, I dont think you should be using a loop at all, based on the fact that a loops job is to run through everything in the loop body automatically.

So how do we solve this? We need to keep track of how many times we’ve clicked that button. First time we click it we only want to show what is being shown in the second picture under the first branch (if-statement) if the statement is true. Second time we only want to do what is being done under the second branch and so on. Fifth time we click the button we want to get back to the first option, and so on.

To keep track of how many times we’ve clicked the button we create an integer variable, name it ButtonClicks. The first thing that happens for the OnClicked event is that we increase this int variable by one. We remove the for loop, and instead we use our int variable with a switch. You can go ahead and remove all the if-statements, the switch will do that job for us. The only thing we need to add to this now is that if the switch goes into number 4, we need to reset the integer variable back to 0. So that the next time we click the button the integer will be set to 1 again, and thus this will become (in a sense) a looping function.

I can send pictures tomorrow if this was not enough :slight_smile:

Ok so I have an array setup with 4 images and 4 skeletal meshes set to a on clicked button…but when i click the button it goes thru them all so fast you cant see them it doesnt stop at each one like when i click 1 time it goes to array 1 when i click again go to array 2 NOPE it goes straight to the 4th array and i cant figure out why.
I have attached pictures of the script.alt text

Could you please send a picture i have no idea how to use those nodes

Thank you so much you have no idea how much this helps me

Sure thing! Here you go, obv I havent filled in every detail, but you should get the general understanding of it :slight_smile:

No worries :slight_smile: I noticed now that I forgot to reset the integer. So when you get to 4 in the switch, after the forloop is completed you should set the int back to 0. That’ll do it!