Commands/gamemode

Sets a player's game mode.


 * Syntax


 * Java Edition


 * Pocket Edition
 * An alternate syntax allows player to enter game mode by its number:
 * An alternate syntax allows player to enter game mode by its number:


 * Arguments


 * mode (PE: gameMode: string or gameMode: int)


 * Must be one of:
 * (can be abbreviated as  or  ) for survival mode
 * (can be abbreviated as  or  ) for creative mode
 * (can be abbreviated as  or  ) for adventure mode
 * (can be abbreviated as  or  ) for spectator mode


 * "hardcore" is not a valid option for the mode argument, as it is technically not a game mode.


 * player (PE: player: target) (optional)


 * If specified, must be either a player's username or a target selector. If unspecified, defaults to the player using the command. When used in a command block, player is not optional.


 * Result


 * Fails if the arguments are not specified correctly, or if player fails to resolve to one or more online players.


 * If successful, changes the game mode of the default or specified players.


 * Examples


 * To put yourself into creative mode:,  , or


 * To put all players into survival mode:  or


 * See also


 * defaultgamemode – sets the initial game mode for players joining the world