#only execute on players

1 messages · Page 1 of 1 (latest)

fair pebble
#

how would i make this only apply knockback to players without the tag in_spawn

world.events.entityHit.subscribe(({ entity, hitEntity }) => {
  if (!hitEntity) return;
  
  const xstr = 5;
  const ystr = 3;

  const direction = hitEntity.getViewDirection();

  let hStrength, vStrength;
  hStrength = Math.sqrt(1 - direction.y ** 2) * xstr;
  vStrength = direction.y * ystr;

  hitEntity.applyKnockback(direction.x, direction.z, hStrength, vStrength);
});```
brittle matrix
#

if

fair pebble
#

code?

#

i aint good lol

brittle matrix
#

omg

#


 
world.events.entityHit.subscribe(({ entity, hitEntity }) => {
  if (!hitEntity) return;
  const xstr = 5;
  const ystr = 3;

  const direction = hitEntity.getViewDirection();

  let hStrength, vStrength;
  hStrength = Math.sqrt(1 - direction.y ** 2) * xstr;
  vStrength = direction.y * ystr;
if (!entity.hasTag(`in_spawn`)) {
  hitEntity.applyKnockback(direction.x, direction.z, hStrength, vStrength);
}
});  ```
hot fossil
#

?js

finite coralBOT
#
Learn Javascript!

As the Script API is a framework built on JavaScript code, having an understanding of JavaScript is key.

If you are being shown this, then you most likely are a beginner with JS and could use a little guidance.

📺 Videos on Learning JavaScript
Javascript in 1 hour
Javascript Classes in 1 hour

Web Guide:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide

Reference Sites:
https://www.w3schools.com/jsref/default.asp
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
https://javascript.info

hot fossil
#

if statements are