Bettergui Plugin Wiki › Guides › Make a menu button run commands, send messages and play sounds
Make a menu button run commands, send messages and play sounds
Use action prefixes
A button's command list holds the actions that run when a player clicks it. Each line starts with a prefix that says how to run it. The prefixes you'll use most are:
console:runs the command as the server console.player:runs the command as the clicking player.tell:sends a message to the player.broadcast:sends a message to everyone.sound:plays a sound to the player.
Check your installed version's docs for the full list. Prefixes can differ slightly between versions.
Chain several actions
Actions run in order, so one click can do several things:
`yaml
kit-button:
slot: 10
id: CHEST
name: "&eStarter Kit"
command:
- "tell: &aEnjoy your kit!"
- "console: give {player} bread 16"
- "sound: ENTITY_PLAYER_LEVELUP"
`
Use {player} where the command needs the clicker's name. Sound names must match valid Minecraft sound names for your server version.
Tips
- Use
console:for commands players can't normally use, such as giving items. Be careful with it, because it bypasses their permissions. - Use
player:when the player should need the normal permission for the command. - If an action does nothing, check the prefix spelling and make sure there is a space after the colon.