#Players index and VS code

1 messages · Page 1 of 1 (latest)

honest cargo
#

Hi, newbie here!
I'm toying around with scripting with Typescript, and I'm wondering how, from a list of players (from world.getAllPlayers()) I can get a player variable (say, from players[0]) to use player methods with. VS code marks players[0] has an error because it cannot know what it is, how can I fix that? I'd like to get to a point where VS code shows me autocomplete for player, even though it comes from a list of players

clever idol
honest cargo
clever idol
honest cargo
#

I've followed the article, I still don't have much things about Intellisense in the way I wanted to

#

I still can't do anything with players[0]

#

I have a script of the likes of:

import { world, Player, Entity, system, ButtonPushAfterEvent } from "@minecraft/server";
let TICK = 0;

function init() {
  world.sendMessage("Test");

}
function ButtonPushed(){
  world.sendMessage("Pushed!");
  let players = world.getAllPlayers;
  let message = players[0].toString;
  world.sendMessage(message);
}

function gameTick() {
  TICK ++;
  if(TICK % 10 === 0){
    //init();
  }

  world.afterEvents.buttonPush.subscribe(ButtonPushed);

  system.run(gameTick);
}

system.run(gameTick);```

Either I run into an error without knowing what, or I'm not doing things the way I should
clever idol
honest cargo
#

T-T nvm had to restart for some reason it fixed everything