#run things until they expire?
1 messages · Page 1 of 1 (latest)
Ok
@high dome yes
think u can do this ```js
function vanish(player) {
new ModalFormData()
.title("Vanish")
.slider("Duration (Minutes)", 1, 5, 1)
.show(player).then(data => {
const duration = data.formValues[0];
const dur = system.runInterval(() => {
for (const player of world.getPlayers()) {
player.runCommandAsync("gamemode spectator @s");
player.runCommandAsync("clear @s");
}
});
system.runTimeout(() => {
system.clearRun(dur);
}, 20 * 60 * Number(duration));
});
}
world.afterEvents.itemUse.subscribe(data => {
if (data.itemStack.typeId === "minecraft:stick") {
vanish(data.source);
clicknoise(data.source);
}
});```