#Trying to write a script to kick players

1 messages · Page 1 of 1 (latest)

jagged lake
#

I imported this code to my script pack, but when I enter my world and give somebody the tag named "Banned", nothing happens. What do i need to fix?

#

import { system } from "@minecraft/server"

const dimension = world.getDimension("overworld")
system.runInterval(() => {
for (const player of world.getPlayers()) {
if (!player.hasTag("Banned")) continue;

dimension.runCommandAsync(`kick ${player.name}`)

}
})

dry spear
#

Import world? And maybe add the tick delay in the runinterval

marsh bobcat
#

you can do player.runCommandAsync("kick @s")

novel spire
#

no u cant

#
import { system, world } from "@minecraft/server"
system.runInterval(() => {
  for (const player of world.getPlayers()) {
    if (!player.hasTag("Banned")) continue;
    player.runCommandAsync(`kick ${player.name}`)
  }
})```
#

try that

jagged lake
#

You goddam legened! It works flawlessly

#

Is there a way i can add a reason for the kick

novel spire
#

like so

#
import { system, world } from "@minecraft/server"
system.runInterval(() => {
  for (const player of world.getPlayers()) {
    if (!player.hasTag("Banned")) continue;
    player.runCommandAsync(`kick ${player.name} you have been banned!!`)
  }
})```