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

How do I allow a script to keep running after calling a function that waits?

Asked by 5 years ago
function waitt()
    wait(10)
end

value.Changed:connect(function()
    blah blah
    blah blah just some code
    waitt()
    blah blah
end

so you see on where I call the function waitt()? How would I continue the script without having to wait for the waitt() function to finish?

0
you can use 2 scripts and use remote functions to make the script trigger Leamir 3138 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

When you call the waitt() function, put it into a spawn() function, so it should look like this:

function waitt()
    wait(10)
end

value.Changed:connect(function()
    blah blah
    blah blah just some code
    spawn(waitt())
    blah blah
end

Honestly, I have never used the spawn() function before, but im 99% sure that this will achieve what you want to do.

Alternatively, you can do coroutines:

function waitt()
    wait(10)
end

value.Changed:connect(function()
    blah blah
    blah blah just some code
    local coro = coroutine.create(waitt)
    coroutine.resume(coro, 'whatever parameters u want for waitt() go into here where this string is')
    blah blah
end

Again, I have never used coroutines, however I have read about them and I'm also 99% sure that they will achive the desired effect for you :D

Ad

Answer this question