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

Why do multiple loops inside a script seem to fail when other loops are running?

Why do multiple loops inside a script (in this case a LocalScript) seem to fail when other loops are running?

1 answer

✓ Accepted answer

Probably because you're using endless loops and not putting coroutines

Say you have this in a script;

while wait(1) do
	print(math.random(1,5))
end

print('Derp')

'Derp' will never be printed, due to the endless loop above it.

So a way to fix? Coroutines.

coroutine.wrap(function()
	while wait(1) do
		print(math.random(1,5))
	end
end)()

print('Derp')

1 comment

0

THankyou

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