#How could i run a command only when the world is created/loaded?

1 messages · Page 1 of 1 (latest)

grand chasm
#
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

lusty turtle
grand chasm
lusty turtle
#

alr then

#

thanks dude

grand chasm
#

when other players join it shouldnt run it

lusty turtle
#

i´ll tell you if it does

#

:D

grand chasm
#

ok

lusty turtle
#

uhh

#

so like

#

when i joined

#

the command started to run almost every tick

#

im not so sure if i did something wrong

grand chasm
#

i may have done something wrong else

lusty turtle
grand chasm
lusty turtle
#

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

grand chasm
lusty turtle
#

oh yeah

#

it does

#

but, there is a way to make it when you load into the game?

#

lol

grand chasm
#

yeah mb , i am to tired to help rn sorry

lusty turtle
#

don´t worry

grand chasm
#

i thought scripts auto reload when you rejoin

#

they dont

#

my fault