How do I fix this?

How do I fix an issue where I have a function in a module that yields the thread, but then If I put a added function under the function that adds the object, nothing fires.

You can wrap the yielding code in a task.spawn(), which basically creates a new thread that won’t yield the code following. For example,

task.spawn(function()
	task.wait(1)
	print("1")
end)
print("2")

Will output:

> 2
> 1

Alternative way to call it is:

function myFunction()
	task.wait(1)
	print("1")
end
task.spawn(myFunction)
1 Like

Do you know how to achieve this in a module?