Does this create infinite coroutines since it is in a while true do loop? If it does, how do you stop the coroutines without putting any code inside the for in pairs do. Thanks!

while true do
	for _, player in pairs(game.Players:GetPlayers()) do
		player.PlayerGui.LocalScript.Disabled = true
		local newThread = coroutine.wrap(function()
			for i = 1, player.leaderstats.Score.Value do
				--Gives experience points					
				end
				wait(0.03125)
			end
		end)
		newThread()
		--No waits allowed
	end
	--Does stuff and waits
end

3 comments

1

What exactly are you trying to do?

0

You should use spawn instead of coroutine.wrap here

0

To stop it: coroutine.yield