You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I just want to know why this isn’t working. -
What is the issue? Include screenshots / videos if possible!
It is supposed to yield the function for 5 seconds but the loop keeps going anyway. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I saw you can only use yield in the coroutine. Is this why? Is there a way to use it outside?
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local function SpawnParts()
while true do
local part = Instance.new("Part")
part.Position = Vector3.new(0,0,0)
part.Parent = workspace
print("Looping")
task.wait(1)
end
end
local Coroutine = coroutine.create(SpawnParts)
coroutine.resume(Coroutine)
task.wait(2)
print("Pause for 5 seconds", coroutine.status(Coroutine))
coroutine.yield(Coroutine) -- Its supposed to stop for 5 sec
task.wait(5)
coroutine.resume(Coroutine)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.