world.beforeEvents.chatSend.subscribe((eventData) => {
const player = eventData.sender;
if (!player.hasTag('admin')) return;
let playerCmds = ["!kick"];
switch (playerCmds.includes(eventData.message.split(' ')[0]) ? eventData.message.split(' ')[0] : eventData.message) {
case '!kick':
eventData.cancel = true;
let otherPlayerName = eventData.message.split(' ').slice(1).join(' ');
let otherPlayer;
for (const player of world.getPlayers()) {
if (player.name == otherPlayerName) otherPlayer = player;
}
system.run(() => {
if (!otherPlayer) return player.runCommand(`tellraw @s {"rawtext":[{"text":"§l§4[Serveur]§cLe joueur §e${otherPlayerName}§c n'est pas connecté!"}]}`);
otherPlayer.runCommand(`tellraw @a{"rawtext":[{"text":"§l§4[Serveur]§c${otherPlayerName} a été expulser par ${player.name}!"}]}`);
player.runCommand(`kick ${otherPlayer}`);
})
break;
default: break;
}
})
#I can't find the error Help me please
1 messages · Page 1 of 1 (latest)
player.runCommand(`kick ${otherPlayer}`);
according to minecraft the error is in this line
you can't find error but you already written it here
I haven't already asked
one thing, you need to learn JS better
player is object thats why its saying Object object
commands are strings so you dont need player but playerName
ok thank you i managed to fix my error
sorry i didn't search enough on my own
I'm a beginner so I'm not necessarily very good
learning only JS will boost you more then developing addons and trying it. look at some tutorials and take some time for that, and that will push you to level what 75% of this community doesn't have
good luck
thank you for your advice