Skip to content

Instantly share code, notes, and snippets.

@Fraktality
Created September 8, 2019 21:49
Show Gist options
  • Save Fraktality/8c113b86ae77cafe4e5ef44c16a31649 to your computer and use it in GitHub Desktop.
Save Fraktality/8c113b86ae77cafe4e5ef44c16a31649 to your computer and use it in GitHub Desktop.
Wait for the first of the passed signals to fire
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