How can i set a correct sequence picking x number of objects?

Have you started on anything yet or are you asking for a tutorial on this? There are a lot of unanswered questions here I feel regarding the implementation and the rules of the “puzzle”.

I guess I can start off by saying that the way I would have done it is creating a Blueprint, call it BP_Puzzle (just guessing you are doing this in blueprint) that contains the boxes and a widget as components. If the player moves up close enough, you get a reference to the BP_Puzzle in your character BP, this way you have a connection between player and puzzle. The cubes are made so that you can interact with them (preferably through collision shape of some sort). The widget has two states, one if the sequence was correct, then it should show the widget, or if it was not correct set a text showing instead.

Interacting with the cubes should maybe be done through a raytrace (however not sure how you intend to interact with them). Store the cubes you clicked on in an array (probably in the BP_Puzzle). When arrays length is equal to number of cubes, compare the set sequence with the array order, if they match set the Widget to showing true sequence, if its false set to show text instead.

Thats a rough sketch, please add more information regarding your needs and I’ll make sure to help you!
Cheers