What is this mean?

Hey, I don’t know what is this mean:
タイトルなし

Did you used devforum or the search bar? There are some posts that may help you:

https://devforum.roblox.com/t/coroutine-vs-spawn-function/153424

Also, I say spawn is bad because it have a delay.

As @TheTurtleMaster_2 said, spawn does have a built in delay, however, it can be useful in some instances, and it is not outdated. However, using the courintine library would be a better method in a lot of cases. If you’re asking what it is, I would ready the posts that he sent in the reply above.

You can make custom spawn using Bindable functions.

1 Like

Some functions, and other built-in methods yield. When something yields, it means that it makes the script stop at a certain point until that something finishes its thing and the script continues. For example, wait(3), it will yield the script for 3 seconds, and after it finished waiting, the script continues.

print("hi") --prints hi
wait(3) --script stops here
print("bye") --after not exactly 3 second, the script continues to print bye

:WaitForChild() yields, it yields until the searched for child is finally loaded.

print("hi")
workspace:WaitForChild("Part") --yields until Part is loaded
print("bye")

Even normal functions written by you yield, if you had a function that basically has a for loop and wait 0.5 seconds each time it loops, that will yield. While loops don’t exactly yield, but basically anything after them will never be executed, since the loop keeps on looping forever.

With spawn(), you basically stop the function from yielding, by creating a new thread, kind of like making another script to run that yielding function on its own.

local function f1()
     wait(3)
end


print("hi") --prints this
spawn(f1) 
print("bye") --and this together, doesn't wait 3 seconds

local function f2()
     while true do 
            wait()
            print("yo")
     end
end


print("hi")
spawn(f2) --keeps on printing yo without stopping the script
print("bye") --prints them together

There are other things that stop yielding such as delay() and couroutines.

It’s not advised to use spawn(), because it creates performance issues, and sometimes when used a lot, it doesn’t stop yielding. Use couroutines instead.

3 Likes