Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a coroutine stop, and then resume again?

How to make a coroutine stop, and then resume again? I do not know why but after the coroutine stops, it breaks the while true do.

local leaderstats = coroutine.wrap(function()
	while wait(0.03125) do
		--My code
	end
end)

while true do
	leaderstats() -- Resumes coroutine
	--My code
	wait(4)
	leaderstats() -- Stops coroutine
	--My code
	wait(4)
end

Thanks!

1 comment

0

It is usually unwise to mix coroutine and wait()

1 answer

✓ Accepted answer

A coupe things I would suggest are googling and looking at the wiki. The wiki is your friend. Beginners Guit to Coroutines and Coroutine Manipulation If you scroll down to the coroutine.yield function I believe this is what you are looking for.

I hope this helped, if it did please accept this as the answer so others know it's been solved. If it didn't work, send me a message or comment and say what went wrong, or just ask any other questions you may have.

2 comments

0

Well I did use the yield function, but I probably used it wrong?

0

Are you saying you were using it before and it didn't work and then you just tried using it again and it did work? Or....?

This discussion is preserved as it was. New answers, comments, and votes are closed.