Which one is better is any one better?
2 Likes
Task.spawn is far better
Task is a new library that should be used instead of spawn, (a lot of things, such as speed benchmarks etc…)
Always try to use task library instead of other functions like wait() spawn() etc
6 Likes
task.spawn
is better since it returns a thread value (spawn
does not) which you can use to cancel the ‘task’ at your own discretion.
local function f()
while true do
print("Hello world!")
task.wait(1)
end
end
local t = task.spawn(f)
task.wait(3)
task.cancel(t)
4 Likes
What exactly is a thread value?
1 Like
One of Lua’s eight native types.
https://www.lua.org/pil/9.html
https://developer.roblox.com/en-us/api-reference/lua-docs/coroutine
2 Likes
A “function”
1 Like