execute if score @s melee_lvl matches 4.. run return run tellraw @s {"text":"You already purchased all melee upgrades!","color":"aqua"}

$execute if score @s melee_lvl matches 0 unless score @s gems matches $(upgrade_melee0).. run return run tellraw @s {"text":"You don't have enough gems! ($(upgrade_melee0)g)","color":"red"}
$execute if score @s melee_lvl matches 1 unless score @s gems matches $(upgrade_melee1).. run return run tellraw @s {"text":"You don't have enough gems! ($(upgrade_melee1)g)","color":"red"}
$execute if score @s melee_lvl matches 2 unless score @s gems matches $(upgrade_melee2).. run return run tellraw @s {"text":"You don't have enough gems! ($(upgrade_melee2)g)","color":"red"}
$execute if score @s melee_lvl matches 3 unless score @s gems matches $(upgrade_melee3).. run return run tellraw @s {"text":"You don't have enough gems! ($(upgrade_melee3)g)","color":"red"}

$execute if score @s melee_lvl matches 0 run function pctf:logic/player/gems/remove {amount: "$(upgrade_melee0)"}
$execute if score @s melee_lvl matches 1 run function pctf:logic/player/gems/remove {amount: "$(upgrade_melee1)"}
$execute if score @s melee_lvl matches 2 run function pctf:logic/player/gems/remove {amount: "$(upgrade_melee2)"}
$execute if score @s melee_lvl matches 3 run function pctf:logic/player/gems/remove {amount: "$(upgrade_melee3)"}

clear @s #pctf:melees

scoreboard players add @s melee_lvl 1

function pctf:logic/player/weapons/melee