How do I see the contents of the 'players' array, my plan is to push a player object with properties into it, is that possible?
This is an example of an array containing player objects↓
Develop games in your browser. Powerful, performant & highly capable.
With scripting that is absolutely possible.
let players = []; // define array const player = runtime.objects.player.getFirstInstance(); // get the player instance you want to put into the array. In this case it will always get the first instance of player which is fine if there's only one player. Otherwise you'll have to get it via uid or loop through all player objects. players.push(player);
Your array now contains the player instance with all it's properties, instance variables etc.
You can show it in the console via a simple console.log(players)
thanks
I mean push like this, is it possible?
Yes that should work perfectly fine too. But You need to have players defined somewhere. A good place would probably be globalThis.