#Any way to detect if the player has taken damage and if yes run a command without changing player.js
1 messages · Page 1 of 1 (latest)
Yes
Il get it now
@sour marlin
const hitPlr = data.hurtEntity
const dmgPlr = data.damageSource.damagingEntity
if (hitPlr.typeId == "minecraft:player") {
hitPlr.runCommandAsync(`title @s actionbar Hello There`)
dmgPlr.runCommandAsync(`title @s actionbar Hello There`)
}
})```
Hit plr is the player who hit the person and dmg is the person whos taken the hit hope it helps 👍
Tnx
Sorry to bother you, but is it possible for you to make this script you made only check a player that has a specific tag? And not all players?
can be "test"
I wanted to add a hit system, so that "blood" would come out of the player when he was hit, you know.
With this system you created, I could use a command to make the particle execute
wdym?
I make make the particle show
Name?
I just need the script to make it happen
sc:blood
Particle name?
Alr
const hitPlr = data.hurtEntity;
const dmgPlr = data.damageSource.damagingEntity;
if (hitPlr.typeId == "minecraft:player" && hitPlr.hasTag("Test")) {
hitPlr.runCommandAsync(`particle ~~1~ cs:blood`);
}
})```
Try it lol
Only the player whos being hit does the particle
~~1~ is one block from the ground
So it looks better
But yh
Ok
Sure
what?
Now that I saw that it doesn't work if I put "!=="
like that:
?
world.afterEvents.entityHurt.subscribe(data => {
const hitPlr = data.hurtEntity;
const dmgPlr = data.damageSource.damagingEntity;
if (hitPlr.typeId == "minecraft:player" && hitPlr.!hasTag("Test")) {
hitPlr.runCommandAsync(particle ~~1~ cs:blood);
}
})
Placing an exclamation mark before "hasTag"?
Wait
k
const hitPlr = data.hurtEntity;
const dmgPlr = data.damageSource.damagingEntity;
if (hitPlr.typeId == "minecraft:player" && !hitPlr.hasTag("Test")) {
hitPlr.runCommandAsync(`particle ~~1~ cs:blood`);
}
})```
This should do it
See the ! By the &&
yh
That is it
So like commands execute at @a[!tag=Test]