#Testing for values in a scoreboard objective, and converting them to UI images
1 messages · Page 1 of 1 (latest)
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")
}
}
}
)
}
})```
use literals
const slot1 = `textures/items/${scoreboard.toString()}`
also write after defining slot1
world.sendMessage(`${slot1}`)
to see if the path is right
and also
const scoreboard = world.scoreboard.getObjective("slot1");
scoreboard.getScore(player)
scoreboard.toString()
this is useless becouse you arent getting score from scoreboard you are just getting something to not use it, you should define that scoreboard.getScore(player) is something, else this is nothing
thats the right way of defining scoreboard
const scoreboard = server.world.scoreboard.getObjective("slot1").getScore(player).toString();