How can I change a user's Gamemode when they step on a certain block?

Solution 1:

The command that you have will test the coordinate -614 81 -923 for stained glass of any color. It will fail to detect if it is not stained glass. It will fail to execute the gamemode command if there is stained glass.

The first problem is that you are testing static coordinates which has nothing to do with which block the player is standing on. It will always test those coordinates regardless of where the player is. In order to test the block under the player, you must use relative coordinates in the detect portion of the execute command: detect ~ ~-1 ~

For the dataValue argument in the detect portion of the execute command you have used -1 which match any block data. In this case, any color of stained glass. You want to specify the block data for yellow stained glass which is 4.

Another problem is the gamemode command sytax is incorrect. You have placed the target selector before the game mode which is backwards.

Also, you used @p as the target selector. I recommend using @s as the target selector. This will select whichever player is executing the command. In this case, whichever player the execute command tested for the stained glass.

This would leave us with: gamemode adventure @s

Here is a working command with all these corrections:

execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:stained_glass 4 gamemode adventure @s

This leaves out the -614 81 -923 coordinates you had specified in the detect portion of the command which means it would test any player any where in the world. If those coordinates are the world spawn, you would add target selector arguments to the original target selector to include those coordinates as well as a radius:

execute @a[x=-614,y=81,z=-923,r=10] ~ ~ ~ detect ~ ~-1 ~ minecraft:stained_glass 4 gamemode adventure @s

This has been tested and works properly. The last command will test the block below any player within a radius of 10 from -614 81 -923. If it is yellow stained glass, the player's gamemode will change to adventure.

Solution 2:

The /gamemode command syntax is:

gamemode (mode) (selector)

You put the selector before, instead of after the mode.

If you just want the answer, I believe you could try something along the lines of:

execute @a[x=-614,y=81,z=-923,r=5] ~ ~ ~ detect ~ ~-1 ~ stained_glass color=yellow gamemode adventure @s