This is what i have: on right click:
if name of player's tool is "&dLegendary Crate"
remove 1 of tool from player's held item
function random(p: player):
set {_random} to random integer between 1 and 2
if {_random} is 1:
send "&dYey! &fYou found diamond!" to {_p}
give {_p} 1 diamond named "&6Gem
if {_random} is 2:
send "&dYey! &fYou found diamond!" to {_p}
give {_p} 2 diamond named "&6Gem
But it will take the crate and dont give items
this are the errors: