I have a solution that uses scoreboard with stat.leavegame
First, you have to create an objective. Type this into chat:
/scoreboard objectives add Leave stat.leaveGame
Then I used two chains of command blocks:
Chain 1
The first command block sends the message to any player not tagged with Sent
. I used tellraw in this example but this is where you would put your actionbar command. It is a repeating / unconditional / always active block with command:
tellraw @a[tag=!Sent] [{"text":"Welcome! You are in arena ","color":"gray"},{"text":"1","color":"red","bold":true}]
The second command block tags the untagged player with Sent
. It is a chain / conditional / always active block with command:
scoreboard players tag @a[tag=!Sent] add Sent
Chain 2
The first command block removes the Sent
tag from any player with a Leave
score of 1 or higher. It is a repeating / unconditional / always active block with command:
scoreboard players tag @a[score_Leave_min=1] remove Sent
The second command block resets the Leave
score of the player with a score of 1 or higher. It is a chain / conditional / always active block with command:
scoreboard players reset @a[score_Leave_min=1] Leave
On first join, player will be sent message and tagged. Once they leave, they will have a Leave
score of one. When they rejoin, they will be untagged, and the score will reset. Then the first chain will send the message and tag them again.
In this example, every time youI join, youI see:
If you are wondering about the lever in my image, both of the repeating command blocks are set to Needs Redstone so I can turn it off.