#LvL Up events
1 messages Β· Page 1 of 1 (latest)
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
if (player.lastLevel === undefined) {
player.lastLevel = player.level
}
if (player.level !== player.lastLevel) {
player.lastLevel = undefined;
player.sendMessage('you leveled up')
}
}
})
there's some issues with this where it would also trigger if you die.
Just make it detect if it is more. Not, !==
?
import { world } from "@minecraft/server";
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
if (player.lastLevel === undefined) {
player.lastLevel = player.level
}
if (player.level !== player.lastLevel) {
player.lastLevel = undefined;
player.sendMessage('you leveled up')
}
}
})
@azure hearth why this isn't working?
There oe something wrong on the way that I put the code?
Is it giving you an error?
yeah that makes sense, I was making this before I went to bed lol
thank you
wdym
it is full.
well it doesn't have the imports, if that's what you mean...
oh I know why it didnt work
you didnt import system...
this is why you need to look at your content logs, and have them on if you dont.
or just make sure you import things you need.
import { world, system } from "@minecraft/server";
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
if (player.lastLevel === undefined) {
player.lastLevel = player.level
}
if (player.level > player.lastLevel) {
player.lastLevel = undefined;
player.sendMessage('you leveled up')
}
}
})
world.afterEvents.playerSpawn.subscribe(data => {
const player = data.player
player.lastLevel = undefined
})```
πππππ
what.
Idk how to script...
I really need a full script tutorial
you can just look up the script api documents and basic javascript tutorials
and look at what people already made here for reference...
hey, idk why but the script somethimes just stop working, and it didnt leave any erros
what it can be?
check the debug