diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index ecacfd6e335..2772043c271 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -3084,6 +3084,12 @@ class PlayState extends MusicBeatState } override function destroy() { + if (psychlua.CustomSubstate.instance != null) + { + closeSubState(); + resetSubState(); + } + #if LUA_ALLOWED for (lua in luaArray) { @@ -3106,12 +3112,6 @@ class PlayState extends MusicBeatState #end stagesFunc(function(stage:BaseStage) stage.destroy()); - if (psychlua.CustomSubstate.instance != null) - { - closeSubState(); - resetSubState(); - } - FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyPress); FlxG.stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyRelease);