How can a non-operator player run this command by clicking on a clickable tellraw text? [duplicate]
The use of scoreboard triggers is a solution to allow non OP players to trigger the execution of op level commands. Current Minecraft Java Edition is 1.12.2
Setup
Create a trigger objective one time manually:/scoreboard objectives add cmdTrigger trigger
Create a command block that is RepeatUnconditionalAlways Active with command:
scoreboard players enable @a cmdTrigger
Setup Commands
Now create a chain of two command blocks. The first command block contains the OP command that you want non OP players to access. This chain will need to be repeated for each command.First command block is RepeatUnconditionalAlways Active with example tp command:
scoreboard teams join Red @a[score_cmdTrigger_min=1,score_cmdTrigger=1]
Second command block is ChainConditionalAlways Active with command:
scoreboard players set @a[score_cmdTrigger_min=1,score_cmdTrigger=1] cmdTrigger 0
For a second command, repeat the two command blocks but use another cmdTrigger score:
scoreboard teams join Blue @a[score_cmdTrigger_min=2,score_cmdTrigger=2]
scoreboard players set @a[score_cmdTrigger_min=2,score_cmdTrigger=2] cmdTrigger 0
Continue with as many chains as you want commands.
Player Run Commands
To use the first OP command the player would have to use command:/trigger cmdTrigger set 1
To use the second OP command the player would have to use command:
/trigger cmdTrigger set 2
Continued for as many commands as you have set up. These can be manually typed into chat by the players but they would have to know what each score does. This is what will be run with your tellraw clickEvent.
Here is an example:
/tellraw @a [{"text":"To join the red team: "},{"text":"[Click Here]\n","color":"red","clickEvent":{"action":"run_command","value":"/trigger cmdTrigger set 1"}},{"text":"To join the blue team: ","color":"none"},{"text":"[Click Here]","color":"blue","clickEvent":{"action":"run_command","value":"/trigger cmdTrigger set 2"}}]