#Spawn with tag
1 messages · Page 1 of 1 (latest)
If player.location is in the interval from min to the max of your area add player.addTag
Else player.removeTag
Are you looking for a pre-made script on how to do this?
I just wanted this
Okay, no problem 👍
No i mean if u have it u can send it lol
Its the same for me
That's what I asked if you wanted the script that does it for you...
import { system, world } from ('@minecraft/server');
// Define the zone (example: coordinates of two opposite corners)
const zone = {
x1: 100, y1: 60, z1: 100, // first corner
x2: 200, y2: 80, z2: 200 // second corner
};
// The tag you want to apply
const tag = 'inZone';
system.runInterval(() => {
for (const player of world.getPlayers()) {
// Get player position
const { x, y, z } = player.location;
// Check if the player is within the defined zone
const inZone = x >= zone.x1 && x <= zone.x2 &&
y >= zone.y1 && y <= zone.y2 &&
z >= zone.z1 && z <= zone.z2;
if (inZone) {
// Add the tag if the player is inside the zone
if (!player.hasTag(tag)) {
player.addTag(tag);
}
} else {
// Remove the tag if the player is outside the zone
if (player.hasTag(tag)) {
player.removeTag(tag);
}
}
}
});```