#Testing for values in a scoreboard objective, and converting them to UI images

1 messages · Page 1 of 1 (latest)

elfin knot
#

Currently I am attempting to convert the number value a player has under a scoreboard, and convert it to a image in a UI, by naming the image the number value. Below I'll post what my attempt was, but the image showed as a missing texture. Any help would be greatly appreciated! (no errors were thrown btw)

#
    let player = event.source
    let itemStack = event.itemStack


    const scoreboard = world.scoreboard.getObjective("slot1");
    scoreboard.getScore(player)
    scoreboard.toString()
    const slot1 = "textures/items/" + scoreboard
    if (itemStack.typeId == "minecraft:compass") {
        new ui.ActionFormData()
            .title("Test")
            .button("Hello", slot1) //First button, the id would be 0, i think. Or 1, idk where it starts counting
            .show(player)
            .then(response => {

                if (!response.canceled) {
                    switch (response.selection) {
                        case 0:
                            player.runCommandAsync("say @s button 0 clicked")
                            break;
                        case 1:
                            player.runCommandAsync("say @s button 1 clicked")
                            break;
                        case 2:
                            player.runCommandAsync("say @s button 2 clicked")
                            break;

                        default:
                            player.runCommandAsync("say @s no button found")
                    }
                }
            }
            )
    }
})```
potent orchid
#
const slot1 = `textures/items/${scoreboard.toString()}`
#

also write after defining slot1

world.sendMessage(`${slot1}`)

to see if the path is right

potent orchid
#

thats the right way of defining scoreboard

const scoreboard = server.world.scoreboard.getObjective("slot1").getScore(player).toString();