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

Function inside while loop makes while loop wait()?

Do functions that are called inside of a while true do loop affect the progress of the loop? For instance

function waitFunction() wait(5) print("function") end

while true do wait(1) print("loop") waitFunction() end

will waitFunction keep the loop from proceeding until it's done?

and if so, how do I avoid that from happening?

thanks!

6 comments

0

There's an accept button by the names of answerers under you're questions. if someone helps you, you click that button to reward reputation to yourself and the person who answered your question. To accept an answer, you click this button. I understand that you're new, but I'm just letting you know :3

0

I'm trying very hard to find said button but I can't see it anywhere. I want to accept you for sure but we are having technical difficulties

0
0

Yeah- this is what I see on my screen https://gyazo.com/e8a0c870d510c89e713f11fdb37d8ef0

0

God I'm hansom. Okay, it's fine :3. You might want to report that bug in the feedback though. Send them the picture too. GL

0

currently troubleshooting this with eryn, i will accept your question eventually i promise haha

1 answer

✓ Accepted answer

Yes.

How to avoid this,

There are a few ways. The first way is the use Coroutines, second Option is to use the Delay function, and last is to use the Spawn Function. I'm familiar with all of these, but I'm best at using Delay, so that's what I'll be using.

function waitFunction()
	print("function")
end

while true do
	wait(1)
	print("loop")
	delay(5,waitFunction)
end

Here's the link to where you can learn more about delay.

Good Luck!

If I helped, please don't forget to accept my answer.

1 comment

0

Awesome! Thank you for your help, delay will work perfectly. I accept your answer

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