Level restart not working properly

Hi, I am building a stealth game in which whenever the player gets caught the level restarts.
To make the level restart I use this event :
1596474498274.png


Normally it works pretty fine but I started using Yep's buttonCommonEvents to use my map abilities as common events (before that I had to copy paste it on each page which isn't so convenient). One of the ability is interefering with the restart event and I'm not sure why.

It's a "phase" ability that allow my player to move forward very quick while being shortly invisible.

"
◆If:Invisible is OFF
◆If:Ability gauge ≥ 2
◆Control Switches:#0003 Invisible = ON
◆Plugin Command:qSight player visible false
◆Play SE:Evasion2 (35, 120, 0)
◆Set Movement Route:Player (Skip, Wait)
:Set Movement Route:◇Opacity:0
:Set Movement Route:◇Speed:6
:Set Movement Route:◇Frequency:5
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇Speed:4
:Set Movement Route:◇Frequency:3
:Set Movement Route:◇Opacity:255
◆Plugin Command:qSight player visible true
◆Control Switches:#0003 Invisible = OFF
◆Control Variables:#0009 Ability gauge -= 2
◆
:Else
◆Text:main character(0), Window, Bottom
:Text:I'm out of energy !
◆
:End
◆
:Else
◆Control Variables:#0003 Disable Lock = 0
◆Plugin Command:qSight player visible false
◆Play SE:Evasion2 (35, 120, 0)
◆Set Movement Route:Player (Skip, Wait)
:Set Movement Route:◇Opacity:0
:Set Movement Route:◇Speed:6
:Set Movement Route:◇Frequency:5
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇1 Step Forward
:Set Movement Route:◇Speed:4
:Set Movement Route:◇Frequency:3
:Set Movement Route:◇Opacity:255
◆Plugin Command:qSight player visible true
◆Control Switches:#0003 Invisible = OFF
◆Control Variables:#0009 Ability gauge -= 2
◆
:End
"

When I start the game, it automatically plays this part :
◆Text:main character(0), Window, Bottom
:Text:I'm out of energy !

And when I restart a level the ability is automatically used even if I'm not pressing the linked key.
I've been trying to figure out what is wrong for a while but I can't get it. Does anyone have an idea ? Or do you know a good plugin that would allow me to restart the level easy ?
You should restructure your event.

One of the biggest (and unfortunately random) problems is that map events only exists on a map.
So if you are transferring the player to a different map, the current map event gets deleted - and that includes the commands after the transfer command.
SOME of the commands will remain in memory until processed, but for any more complex structures it is usually better to have an event end at the transfer command and have an autorun on the target map continue with the rest of the commands.

and since you have multiple transfers in that event, probably back to this map from what you're writing, you need to be rather tricky on which command is triggered when.
You'll probably have to continue the bughunt after restructuring the events, but first you need to get that problem above fixed before you can search for the next bug.
Alright thanks ! I'm gonna try to just remake the event cleaner then 😀
So well, I fixed it but that was the weirdest thing ever.
Basically the event was good. But for some reason when I placed in in common event 11 it just bugged (maybe something in yanfly's pluging ?). I put it in an other slot and now it works just fine. I spent hours to try to fix this haha

Original thread: https://forums.rpgmakerweb.com/threads/level-restart-not-working-properly.124871/