#how to delete an item from head if durability is 0

1 messages · Page 1 of 1 (latest)

rotund dragon
#

how do i fix this

system.runInterval(() => {
    for (const player of world.getPlayers()) {
        const playerEq = player.getComponent('equippable');
        const headEquipment = playerEq.getEquipment(EquipmentSlot.Head);
        if (!headEquipment || headEquipment.type.id !== 'btm:night_helmet') continue;
        const durabilityComponent = headEquipment.getComponent('durability');
        durabilityComponent.damage += 1;
        playerEq.setEquipment(EquipmentSlot.Head, headEquipment);
        if (durabilityComponent === 0) {
            playerEq.setEquipment(EquipmentSlot.Head);
        }
    }
}, 1);
#
system.runInterval(() => {
    for (const player of world.getPlayers()) {
        const playerEq = player.getComponent('equippable');
        const headEquipment = playerEq.getEquipment(EquipmentSlot.Head);
        if (!headEquipment || headEquipment.type.id !== 'btm:night_helmet') continue;
        const durabilityComponent = headEquipment.getComponent('durability');
        durabilityComponent.damage += 1;
        if (durabilityComponent.damage === 0) {
            playerEq.setEquipment(EquipmentSlot.Head, null);
        } else {
            playerEq.setEquipment(EquipmentSlot.Head, headEquipment);
        }
    }
}, 1);
novel monolith
#

Hmmm

#

Are u using phone or pc ?

rotund dragon
#

pc

earnest ember
#

so if damage equals zero, it should remove it from the players head?

marsh nacelle
marsh nacelle
#

0 is the item durability being fixed

#

Like normal

marsh nacelle
earnest ember
#

yah, i was wondering what he was tryna do, cuz if its zeroz then its not damaged at allz right?

marsh nacelle
earnest ember
#

no, thats why u use questions

marsh nacelle
#

You didn't even tell him about the maxDurability part of the durability component blud

#

Stop with the ego

earnest ember
#

?

marsh nacelle
#

Actually i think I'm the one with it....

#

Sorry i guess.

earnest ember
#

i dont understand