Okay, so here is what I have now:
import { world, Player } from "@minecraft/server";
const mobTypes = [
"minecraft:chicken"
];
const scoreboard = world.scoreboard
const score = scoreboard.getObjective("job_hunter_lvl")
world.afterEvents.entityDie.subscribe((event) => {
const player = event.damageSource.damagingEntity;
const scores = score.getScore(player);
if (!player) return;
if (!(player instanceof Player)) return;
mobTypes.forEach((id) => {
if (mobTypes.matches(id) && scores < 6) {
event.player.dimension.runCommand(
`particle minecraft:basic_flame_particle ${event.mobTypes.x} ${event.mobTypes.y} ${event.mobTypes.z}`
);
let players = world.getAllPlayers();
for (let player of players) {
player.runCommand("scoreboard players add @s job_hunter_xp " + 1);
player.runCommand("playsound random.orb @s ~~~ 1 1");
player.runCommand("function level_up")
}
return;
}
});
});
But I am now getting the error
[Scripting][error]-TypeError: not a function at <anonymous> (HunterTest.js:18)
at forEach (native)
at <anonymous> (HunterTest.js:31)
and I am still getting
[Scripting][error]-TypeError: Native variant type conversion failed. at <anonymous> (HunterTest.js:11)
I am sorry for being such a noob, just really struggling to get my head round this