Created
September 8, 2019 21:49
-
-
Save Fraktality/8c113b86ae77cafe4e5ef44c16a31649 to your computer and use it in GitHub Desktop.
Wait for the first of the passed signals to fire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function waitForFirst(...) | |
local shunt = Instance.new("BindableEvent") | |
local slots = {...} | |
local function fire(...) | |
for i = 1, #slots do | |
slots[i]:Disconnect() | |
end | |
return shunt:Fire(...) | |
end | |
for i = 1, #slots do | |
slots[i] = slots[i]:Connect(fire) | |
end | |
return shunt.Event:Wait() | |
end | |
return waitForFirst |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment