Minecraft – Player Save State for Game Mode

minecraft-bedrock-editionminecraft-commands

On our server I'd like to switch people to adventure when they enter an area, but when they leave it should set them back to the game mode they were in before entering.

So my question is, is it possible to record player information in the scoreboard or a tag for their game mode and then use it later

e.g. tag @s add GameMode=[m]

Best Answer

When they enter the area do:

/tag @a[m=s] add survival

And:

/tag @a[m=c] add creative

And:

/tag @a[m=a] add adventure

Then just change their gamemodes back later accordingly:

/gamemode a @a[tag=adventure,r=5]

etc.

Make sure to untag them:

/tag @a[tag=survival,r=5] remove survival