Character position always starting scene

Hello,

i am in working progress to establish a random encounter in my rpg game.
when i start the encounter scene out of the main scene, where the main map is constituted, and the character chooses to flee or the encounter ends, the character position is set to the beginning position of the world map.

i think i miss code to establish, that the character position stays on the last position.
i coded a boole with is set to true when the main map starts to set up the position at the beginning.
in the encounter scene i set the boole to false, to avoid the code to go “back” to the starting position.
it does not work.
can someone help me to get the right code?

greetings

WHEN player encounter enemies
You have some action to change scene and go to encounter scene

Create two GLOBAL number variables name them PosX PosY
On top of actions in that event put change PosX set to Player.X()
Change PosY Set to Player.Y()

And now when you get back from encounter scene to your main scene change player position to PosX PosY