#How would I make this for loop not wait for the function to finish before it loops again

1 messages · Page 1 of 1 (latest)

sinful dune
#

I want to make it so it can keep spawning goobers without waiting for the MoveGoober() function to finish.
Unfortunately I don't know enough about coroutines to figure this out so I need some help

sinful dune
#

Yes !

serene reef
sinful dune
#

I tried using coroutine.wrap on the move function

serene reef
#

simpler version of corutines

#

is just task.spawn

#

have u ever used it?

sinful dune
#

I havent

serene reef
#

its wayy simpler but bit less control

serene reef
#
task.spawn(function()
CODE

end)
#

and the code inside it

#

will run along other

#

so if u put the whole loop in this

#

it will run the loop in background basically

#

working as u want

sinful dune
#

Ohh

#

What will happen if i use the task.spawn for the MoveGoober function instead?

serene reef
#

all code inside task.spawn will run in background

#

so it wont wait for the code to be done

#

before going to next line

sinful dune
serene reef
#

is MoveGoober the function that takes time?

#

or the loop

sinful dune
#

MoveGoober

serene reef
#

ok so

#

you can just task.spawn the movegoober

#

but

#

i think its just better if u task.spawn the whole function

#

cuz many task.spawns can also slighty affect peformance

#

but depending on your needs u might need to just task.spawn the movegoober yea

sinful dune
#

I see, i did try task.spawn on the move function but it gave the same issue using coroutine.wrap does

#

hold on ill record it

#

what the shit

#

now its not doing that ?

#

ohh wait

#

I get it

#

It does it when trying to spawn multiple things from the howmany thing

serene reef
sinful dune
#

the first one is the broken one, it spawns 2 goobers
the second one is the normal one

mild verge
#

No, use task.spawn({your function})