#HELP IN SCRIPTING
1 messages · Page 1 of 1 (latest)
have u tried with a lot of items in ur inventory?
wdym?
random items in ur inv
like have i tried with other items then my custom key
yeah
i tried with doiamonds and it works
const inv = plr.getComponent("inventory").container
let crate_key = 0
for (let i = 0; i < inv.size; i++) {
const item = inv.getItem(i)
if (!item || item.typeId !== 'mystic:rare_crate_key') continue
crate_key += item.amount
}
if (crate_key) plr.runCommandAsync(`scoreboard players set @s rarekey ${crate_key}`)
else plr.runCommandAsync(`scoreboard players set @s rarekey 0`)
I'd use the cmd outside of the loop if that's what should be done
alr thanks