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

Is there a way to run a portion of code without yielding the script?

Asked by 6 years ago

Basically what I mean by this is something like this

local function test()
    print('abc')
    wait(1)
end

test()
print('this printed one second after abc assuming server didnt wait longer')

What I want to do is make that second print() occur right after abc is printed while still having the wait in the function

1 answer

Log in to vote
0
Answered by 6 years ago

You cannot remove a yield from a script but you can use spawn or even delay

More infomation can be found on the threading wiki page.

Example:-

local function test()
    print('abc')
    wait(1)
    print('test end')
end

spawn(test)
print('this printed one second after abc assuming server didnt wait longer')

I hope this helps.

Ad

Answer this question