$execute if entity @s[tag=!Player.Selected_Happy_Ghast] if entity @n[type=minecraft:happy_ghast,nbt={data:{Owner:$(UUID)}},distance=..100] run function better_happy_ghast:tick/player/happy_ghast_order_menu/select_nearest_happy_ghast/check_where_player_looks {UUID:$(UUID)}

$execute if entity @s[tag=!Player.Selected_Happy_Ghast] if entity @n[type=minecraft:happy_ghast,nbt={data:{Owner:$(UUID)}},distance=..100] run data modify storage better_happy_ghast:selected_happy_ghast players[{UUID:$(UUID)}].Selected set from entity @n[type=minecraft:happy_ghast,nbt={data:{Owner:$(UUID)}},distance=..100] UUID
$execute if entity @n[type=minecraft:happy_ghast,nbt={data:{Owner:$(UUID)}},distance=..100] run tag @s[tag=!Player.Selected_Happy_Ghast] add Player.Selected_Happy_Ghast

$function better_happy_ghast:tick/player/happy_ghast_order_menu/select_nearest_happy_ghast/exe with storage better_happy_ghast:selected_happy_ghast players[{UUID:$(UUID)}]

execute if score @s[tag=!Player.Selected_Happy_Ghast] happy_ghast matches 2 run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§8[§bSky Deck§8] §cNo tamed Happy Ghast found within 100 blocks."
execute if score @s[tag=!Player.Selected_Happy_Ghast] happy_ghast matches 2 run playsound minecraft:block.amethyst_block.step ui @s[scores={better_happy_ghast.player_configs.play_sound=1}] ~ ~ ~ 1 0.8

tag @s[tag=Player.Selected_Happy_Ghast] remove Player.Selected_Happy_Ghast