Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Function inside while loop makes while loop wait()?

Asked by 8 years ago

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!

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 User#11440 120 — 8y
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 patrline5599 150 — 8y
0
That's fine. Here's an example, https://gyazo.com/be3eabea78f3ac76eca23ea8f6c82244 User#11440 120 — 8y
0
Yeah- this is what I see on my screen https://gyazo.com/e8a0c870d510c89e713f11fdb37d8ef0 patrline5599 150 — 8y
View all comments (2 more)
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 User#11440 120 — 8y
0
currently troubleshooting this with eryn, i will accept your question eventually i promise haha patrline5599 150 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

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.
0
Awesome! Thank you for your help, delay will work perfectly. I accept your answer patrline5599 150 — 8y
Ad

Answer this question