Chest game?

I have 3 chests, I want to give the player 2 tries to find X and if he doesn't pick the right chest, the game resets and he starts over again, how would I do this, please, if anyone has the patience to explain it to me, it would really be appreciated
Also, if this is in the wrong category, I apologize
on the first page of the wrong chests, have all of them flip a switch when opened. then have the second page's condition for them be that that switch is active, and make them reset the game and that same switch if chosen
@Robro33 that wouldn't be a clean solution though to flip a switch
when wrong, this is best based on a variable as this can control
when open and wrong + if the chest is random, this would not work.

@User1978 this can best be done by 2 variables, but mostly like
a scriptcall as well to reset the self switches back OFF.

1) random variable (0,1,2) this one is chose from when entering the room,
or run based on another selfswitch (if running on parallel) as this will switch
back to a blank page.

1 variable = wrong picking.

the parallel you should run is simple of 2 pages.
page 1: (parallel)
random variable x = 0...1
selfswitch A = ON

page 2: (action buton)
blank

chests can be a bit trickier based of a fixed solution so you need to make
multiple pages.

page 1: (action button, required random variable = 0)
page 2: same as above, but random variable = 1
page 3: same as 2, but random variable = 2
page 4: selfswitch A = on

so on page 1:
increase variable y = +1 (wrong answer)
text: nothing in here (change what you want to do)
selfswitch A = ON

page 2 can be the same if wrong answer else X is found
page 3 the same as 2, depends on the answer.

if page 2 is correct on chest 1, chest 2 and 3 need to be false.

opening a chest is same as create a chest, but you can adjust it the way
on the correct/wrong answers.

than use the scriptcall if variable wrong answers = 2
let key = [this._mapId, [2,3,4,x], "A"]
$gameSelfSwitches.setValue(key, false)

the array [2,3,4,x] are the event Id's you want to reset.
you can also do each seperately as well, but this is the easiest and best
way in my opinion, so you cannot go wrong.
just make 3 chests. then add fade in, set the location of the chest to 3 random positions, fade out. set variables "Try" equal to 2. Set up normal quick event chest on each chest , decrease try by 1 before the Self Switch A is ON. add conditional branch if TRY = 0, call common event "Reset Chests on Map"

create the common event "Reset" return the chests and players to their original position.

create the first event that the auto Run event will call -> randomize chest position. Since there are only three positions, it will only 6 distinct arrangements ABC, ACB, BAC, BCA, CAB, CBA. By setting to auto run, the event will always be the first to run when entering the map. Also, dont forget to have a switch "Chest Game" is ON at the start and turn it OFF during reset or when the correct chest is found.

Or simply you can just random 1,2,3.. if 3, then give the reward.
Does this work in RPG maker MZ?
Because I am working on a game on it, and this would be a cool puzzle.

@Robro33 that wouldn't be a clean solution though to flip a switch
when wrong, this is best based on a variable as this can control
when open and wrong + if the chest is random, this would not work.

@User1978 this can best be done by 2 variables, but mostly like
a scriptcall as well to reset the self switches back OFF.

1) random variable (0,1,2) this one is chose from when entering the room,
or run based on another selfswitch (if running on parallel) as this will switch
back to a blank page.

1 variable = wrong picking.

the parallel you should run is simple of 2 pages.
page 1: (parallel)
random variable x = 0...1
selfswitch A = ON

page 2: (action buton)
blank

chests can be a bit trickier based of a fixed solution so you need to make
multiple pages.

page 1: (action button, required random variable = 0)
page 2: same as above, but random variable = 1
page 3: same as 2, but random variable = 2
page 4: selfswitch A = on

so on page 1:
increase variable y = +1 (wrong answer)
text: nothing in here (change what you want to do)
selfswitch A = ON

page 2 can be the same if wrong answer else X is found
page 3 the same as 2, depends on the answer.

if page 2 is correct on chest 1, chest 2 and 3 need to be false.

opening a chest is same as create a chest, but you can adjust it the way
on the correct/wrong answers.

than use the scriptcall if variable wrong answers = 2
let key = [this._mapId, [2,3,4,x], "A"]
$gameSelfSwitches.setValue(key, false)

the array [2,3,4,x] are the event Id's you want to reset.
you can also do each seperately as well, but this is the easiest and best
way in my opinion, so you cannot go wrong.
@Jayjayjangles ...did you try?

There are no differences in these basic event commands between MV and MZ.

Also, as a tip, we're encouraged to just use the default text color, otherwise you may cause problems for people trying to read your posts on either the light or dark theme.
I am going to, just making sure that it works between both versions.
@Jayjayjangles Do not post disruptively. This includes but is not limited to: thread hijacking (posting in another person's thread with your own questions/resources, etc. that leads the focus away from the original topic and onto you). You can read all the forum rules here.
@Jayjayjangles Do not post disruptively. This includes but is not limited to: thread hijacking (posting in another person's thread with your own questions/resources, etc. that leads the focus away from the original topic and onto you). You can read all the forum rules here.
Got it, sorry for any inconvenience.
Thank you guys for the in-depth answers, I really do appreciate the time you put into them, I'm gonna try these out

Original thread: https://forums.rpgmakerweb.com/threads/chest-game.164635/