I've added a creative region to my survival world and when players enter/exit that region, I want to display a title and subtitle like so:
This is easy enough to do with the
title command and a command block, but I'm having trouble getting the title to only display for players entering/exiting the area.
Currently, I'm trying to chain command blocks to accomplish this task, but I'm not against crafting a function for it, as that's the end goal anyways (though I need the command block way first because my behavior pack isn't ready yet). The setup is currently:
# Block 1 (Repeat, Unconditional, Always Active) tag @a[r=64] add "home" # Block 2 (Chain, Conditional, Always Active) gamemode creative @a[r=70,tag="home"] # Block 3 (Chain, Conditional, Always Active) tag @a[r=70,tag="home"] add "home-title" # Block 4 (Chain, Conditional, Always Active) title @a[r=70,tag="home-title"] subtitle "This is a safe space." # Block 5 (Chain, Conditional, Always Active) title @a[r=70,tag="home-title"] title "Home Base"
There are three other command blocks that are responsible for the exit process, all of which are set to:
- Always Active
Their commands are:
# Block 1 tag @a[rm=65] remove "home" # Block 2 tag @a[rm=65] remove "home-title" # Block 3 gamemode survival @a[rm=65]
My thought process was that for players that already have the home tag, the remaining blocks wouldn't execute, however this is not a true statement, and in hindsight, it never could've been since all remaining blocks impact all players within a 64 block radius.
How can I adjust my setup to ensure only players that are entering/exiting the area will see the title/subtitle with command blocks?
Bonus: Can it be done in a single function?