#How could i run a command only when the world is created/loaded?
1 messages · Page 1 of 1 (latest)
system.runTimeout(() => {
const players = world.getPlayers();
for (let player of players) {
//your code
}
}, 5);
if you just put this outside any of your other code it should run when you join the world or /reload
would the other players run the command too?
tbh idk, i think this only runs when you first join the world but you should test it
when other players join it shouldnt run it
ok
OK
uhh
so like
when i joined
the command started to run almost every tick
im not so sure if i did something wrong
make sure its outside of ur other code
i may have done something wrong else
doing that rn
u could also just remove the timeout and it would probably still work
okay
i have put it ouside of my other code
but when i did that, it stopped working?
system.runTimeout(() => { const players = world.getPlayers(); for (let player of players) { player.runCommand("function main_stuff"); } }, );
i didn´t make a lot of changes so
does it work when you reload
oh yeah
it does
but, there is a way to make it when you load into the game?
lol
yeah mb , i am to tired to help rn sorry
oh it´s fine dude!
don´t worry