$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=!Happy_Ghast.Is_Mounting] at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=!Happy_Ghast.Is_Mounting] if entity @e[limit=1,nbt={UUID:$(to_mount)}] run tag @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=!Happy_Ghast.Is_Mounting] add Happy_Ghast.Is_Mounting

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] run tag @e[limit=1,nbt={UUID:$(to_mount)}] add Happy_Ghast_Passenger.Mounted

$scoreboard players set @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] better_happy_ghast.happy_ghast.passengers_count 0
$execute as @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] if predicate better_happy_ghast:have_any_passengers on passengers on vehicle unless score @s better_happy_ghast.happy_ghast.passengers_count matches 4.. run scoreboard players add @s better_happy_ghast.happy_ghast.passengers_count 1

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] unless score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches 4.. unless data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] ",{selector:"@e[limit=1,nbt={UUID:$(to_mount)}]"}," §aas been mounted on the Happy Ghast"]
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] unless score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches 4.. if data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] ",{selector:"@e[limit=1,nbt={UUID:$(to_mount)}]"}," §aas been mounted on the Happy Ghast named \"",{selector:"@e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Mounting]"},"§a\"."]
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] unless score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches 4.. run playsound minecraft:block.note_block.snare master @s[scores={better_happy_ghast.player_configs.play_sound=1}] ~ ~ ~ 1 2

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=!Happy_Ghast.Is_Mounting] unless data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §cThere is no mob that can be mounted on the Happy Ghast in a distance of 6.5 blocks."
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=!Happy_Ghast.Is_Mounting] if data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §cThere is no mob that can be mounted on the Happy Ghast named \"",{selector:"@e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=!Happy_Ghast.Is_Mounting]"},"§c\" in a distance of 6.5 blocks."]
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=!Happy_Ghast.Is_Mounting] run playsound minecraft:block.note_block.snare master @s[scores={better_happy_ghast.player_configs.play_sound=1}] ~ ~ ~ 1 0.5

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,scores={better_happy_ghast.happy_ghast.passengers_count=..3},tag=Happy_Ghast.Is_Mounting] at @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting] run ride @e[limit=1,nbt={UUID:$(to_mount)}] mount @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5,tag=Happy_Ghast.Is_Mounting]

$tag @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=Happy_Ghast.Is_Mounting] remove Happy_Ghast.Is_Mounting

$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] unless data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName if score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches 4.. run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §cThe places of the Happy Ghast are full."
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] if data entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}}] CustomName if score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches 4.. run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] ["§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §cThe places of the Happy Ghast named \"",{selector:"@e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},tag=!Happy_Ghast.Is_Mounting]"},"§c\" are full."]
$execute if entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] unless score @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] better_happy_ghast.happy_ghast.passengers_count matches ..3 run playsound minecraft:block.note_block.snare master @s[scores={better_happy_ghast.player_configs.play_sound=1}] ~ ~ ~ 1 0.5

$execute unless entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] run tellraw @s[scores={better_happy_ghast.player_configs.send_message=1}] "§7[§r§6§lBetter §r§7§lHappy Ghast§r§7] §cNo selected Happy Ghast as been found in a distance of 6.5 blocks."
$execute unless entity @e[type=minecraft:happy_ghast,limit=1,nbt={UUID:$(Selected),data:{Owner:$(UUID)}},distance=..6.5] run playsound block.note_block.pling master @s[scores={better_happy_ghast.player_configs.play_sound=1}] ~ ~ ~ 1 0.5