system.runInterval(() => {
for (const player of world.getPlayers()) {
if (player.hasTag("smnt")) {
if (player.getScore("smnt",(7..))) {
player.runCommand("scoreboard players add @s smnt 1");
} else {
player.runCommand("scoreboard players set @s smnt 0");
player.removeTag("smnt");
}
}
}
}, 1);
## help me
1 messages · Page 1 of 1 (latest)
added , (comma) when calling the getScore function
If it still doesn't work, then you need to explain more detail about these things:
- Send your
getScorefunction - Player class do not have a native method
getScore()
error
I added it to the Player object prototype and posted that it in general to soemone idk if he is using that
use this
import {Player} from '@minecraft/server'
Player.prototype.getScore = function (objectiveName){
return world.scoreboard.getObjective(objectiveName).getScore(this.scoreboardIdentity)
}
//Example Use
if(player.getScore('Random Objective') === 3){
//DO something
}
honestly, why doesn't he just use the matches method and use the EntityQueryOption for scores
error in 7.(.)
const testOption = {
scoreOptions: [
{
minScore: 7,
objective: "smnt"
}
]
}
system.runInterval(() => {
for (const player of world.getPlayers()) {
if (player.hasTag("smnt")) {
if (player.matches(testOption))) {
player.runCommand("scoreboard players add @s smnt 1");
} else {
player.runCommand("scoreboard players set @s smnt 0");
player.removeTag("smnt");
}
}
}
}, 1);
in vs code
bruh
const testOption = {
scoreOptions: [
{
minScore: 7,
objective: "smnt"
}
]
}
system.runInterval(() => {
for (const player of world.getPlayers()) {
if (player.hasTag("smnt")) {
if (player.matches(testOption)) {
player.runCommand("scoreboard players add @s smnt 1");
} else {
player.runCommand("scoreboard players set @s smnt 0");
player.removeTag("smnt");
}
}
}
}, 1);
removed that extra )