import { system, world } from '@minecraft/server'
import * as lib from '../template'
system.runInterval(() => {
for (const player of world.getPlayers()) {
current(player)
}
}, 5)
export function current(player) {
player.getComponent("minecraft:health").current > lib.scoreboard.get(player, `hp`) && lib.scoreboard.get(player, `hp`) > 0 ? player.getComponent("minecraft:health").setCurrent(lib.scoreboard.get(player, `hp`)): null
}
#This little script of mine doesn't work at all... πDoes anyone out there know how to fix it?
1 messages Β· Page 1 of 1 (latest)
@glossy fern
This system identified any type of damage
do u have typings installed?
I didn't understand
I do everything on my cell phone, my friend
I just noticed that it is "Export function"
I'll check if that's the problem
Nothing makes this system work
Does not make sense
it worked before
@autumn mesa
hb this
function current(player) {
player.getComponent("minecraft:health").currentValue > lib.scoreboard.get(player, `hp`) && lib.scoreboard.get(player, `hp`) > 0 ? player.getComponent("minecraft:health").setCurrentValue(lib.scoreboard.get(player, `hp`)) : null
}
I will try one more time
Doesn't work ππππππ
;-;
It's like the command doesn't exist
whats in ur lib
I've been trying to fix it since yesterday, but nothing seems to make sense.
My lib is working
I know this because I have other systems that use lib.score
and is this file imported?
Like this?
I put it on and nothing appears inside
But I'll see what happens
the its using a different pack...
Calm
I put a runInterval in the file
Maybe it wasn't showing up before because the runinterval was in another file
Give me one second
@autumn mesa
function current(player) {
console.warn(player.getComponent("minecraft:health").currentValue > lib.scoreboard.get(player, `hp`) && lib.scoreboard.get(player, `hp`) > 0 ? player.getComponent("minecraft:health").setCurrentValue(lib.scoreboard.get(player, `hp`)) : null)
}
ok
now split them into variables
before doing setCurrent
console.warn those variables
function current(player) {
const health = player.getComponent("minecraft:health").currentValue
const hp = lib.scoreboard.get(player, `hp`)
console.warn(health, hp);
}
Oh
Need anything else?
is ur score 0?
does it work when u set it to 1+
I'll try
do u want that hp 0 to kill the player?
Just like you saw in the script
Current health cannot be greater than the "hp" score or less than 0...
This system used to work perfectly but suddenly it stopped working and I can't understand the reason ππππ
now try this
function current(player) {
const health = player.getComponent("minecraft:health")
const hp = lib.scoreboard.get(player, `hp`);
health.currentValue > hp && hp >= 0 && health.setCurrentValue(hp);
}
Oukay sir
My God
It looks like it worked
I will test some more
thanks a lot man
You don't know how happy I am
πππππ

I still don't know how to do this
Here you used console.warn at the end
There's nothing inside it
Ooooh, I understand
Did you turn it into a code without the "?:"
u can also do ```js
console.warn(health.currentValue > hp && hp >= 0)
yea
true && console.log('logged1')
false && console.log('logged2')