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

How can I run 2 events at the same time?

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

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

2 comments

0

That didn't work, it did the same thing: wait for 1 of the buttons to be pressed and not the other.

0

experiment with it dont just copy and paste

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