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

How can I run 2 events at the same time?

Asked by 4 years ago

I made an Installer for my plugin and most of the questions have 2 answers. So if anyone of them is clicked, it will continue. So I coded the following:

repeat
    wait(.01)
until [BUTTON].MouseButton1Click:Wait() or  [BUTTON2].MouseButton1Click:Wait()

However, it didn't continue for the second answer.
Can anyone help? Thanks in advance!

1 answer

Log in to vote
0
Answered by 4 years ago

Try making new threads:

Either by function spawn or manipulating with coroutines.

-> https://developer.roblox.com/en-us/articles/Beginners-Guide-to-Coroutines

Here's my example:

-- This whole script is just one big thread. Code runs here
coroutine.resume(coroutine.create(function() -- This creates a thread with the provided function and runs it .
    repeat
        print('wow coroutine 1')
        wait(3)

    until workspace:FindFirstChild('Stop')
end))
coroutine.wrap(function()-- this does both of them once but with the two parenthesis at the End
    repeat
        print('wow coroutine 2')
        wait(3)
    until workspace:FindFirstChild('Stop')
end)()

print('wow coroutine 3')-- since both loops are in two different threads this print function will work
0
That didn't work, it did the same thing: wait for 1 of the buttons to be pressed and not the other. ViviTheLuaKing 103 — 4y
0
experiment with it dont just copy and paste SoftlockedUnderZero 668 — 4y
Ad

Answer this question