#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#
#    This function has been created by Skilendarz Group.
#             https://skilendarz.com
#
#      GIVE MAP MAKERS THE CREDIT THEY DESERVE!
#             COPYING IS PROHIBITED!
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

tag @s[scores={compass_cost=0}] remove has_gold
tag @s[scores={gold=1..}] add has_gold

scoreboard players set @s[tag=!hold_compass] compass_cost 0
scoreboard players add @s[tag=hold_compass,tag=has_gold] compass_cost 1

#Take gold
execute at @s[scores={compass_cost=2}] run playsound minecraft:item.axe.scrape master @s ~ ~ ~ 1 1.5
clear @s[scores={compass_cost=2}] gold_ingot 1
scoreboard players remove @s[scores={compass_cost=2}] gold 1

#Deactivate
execute at @s[scores={compass_cost=21,gold=0}] run playsound minecraft:block.beacon.deactivate master @s ~ ~ ~ 1 2
scoreboard players set @s[scores={compass_cost=21..}] compass_cost 0