execute if score @s ranged_enchant_lvl matches 1.. run return run tellraw @s {"text":"You already purchased all ranged enchants!","color":"aqua"}

$execute if score @s ranged_enchant_lvl matches 0 unless score @s gems matches $(enchant_ranged0).. run return run tellraw @s {"text":"You don't have enough gems! ($(enchant_ranged0)g)","color":"red"}

$execute if score @s ranged_enchant_lvl matches 0 run function pctf:logic/player/gems/remove {amount: "$(enchant_ranged0)"}

clear @s minecraft:bow

scoreboard players add @s ranged_enchant_lvl 1

function pctf:logic/player/weapons/ranged