Need help to optimize my blocks

Hi !

I would like to have your help for the optimization of some of my blocks, because I repeat 4 times an action which is similar to 4 buttons. But I can’t. Here are my unoptimized blocks:

And here is what I tried to do:


I think I am not far from the solution, but there are bugs. For example, the color or sound change actions occur even on a button that is not in the list.
Or, I have the impression that as soon as I click on one of the buttons, the actions occur endlessly (I think the loop should be stopped, but I can’t).

So, if anyone here would be kind enough to help me solve my problem, that would be great fun! Thanks everyone!

I hope you are making too complicate with more blocks… You can shorten the blocks with any button click…

If the text of the clicked component = answer text
then play correct
else play wrong… simple…

Why are you adding or using multiple loop over there?

Because I have 4 buttons, 3 is the wrong answer and 1 is the correct one.

I would like that if I click on a wrong answer, the background color of the button turns red, and the button of the correct answer turns green.

But I must surely make it difficult for myself, that’s why I’m asking for your help

And above all, why the other buttons on the screen that are not in the list behave the same as if I had included them in the list?

let me show sample block existing in one project

Here instead of label, you can use button component

No, I do not understand. What I am trying to do is very simple I think, but impossible to achieve.

Why does it not take into account ONLY the buttons that I put in the list? No matter which button I click, it takes into account the actions I have in “for each element of list”.

And I can’t change the color of the right answer button when I click on the wrong one.

The reason is, you have not used anywhere the item… You have used only component, if so it will account all the buttons.

Well that’s exactly the same problem …

If you are using for each item block, then you should not use direct index here, then there is no use of the block. You need to try to find the index by using index is in the list thing( item ) lost get gKobal answer button.

Actually what are you trying aar here, you news to add the colour only here…

You need to replace the item with select list item list (get global button) index (index is in the list thing (component ) list (get global answer button)

But this index is linked to my custom color list, it’s to avoid having color building blocks every time, so it doesn’t relate, does it?

Ok ok, i got it. Pls try to change the item only as said above

I don’t understand what you’re asking me to try, change what, please?

Ok, pls have a look at this post and developers your idea for color change

It is exactly the same problem. I really do not understand. I really need help please :confused:

It would be easier if you provided a test aia

Watch the video, normally there is a sound for the correct answers, and a sound for the wrong answers (and in addition a vibration when it is wrong).

No matter what answer I choose, I have both sounds playing at the same time and the vibration too, and no matter which button I click, it’s the same, even if I click on the “Pause” button in bottom of the screen

I’ll try this, okay

So, I quickly reproduced the situation on this aia test.

You have to refresh to start over, but I have the same problem as on my project.

No matter which button you press, both sounds are played, and even with buttons that are not in the list, like the test button at the bottom.

test_btn.aia (99.6 KB)