Wait & Query
Yield the current coroutine until a named event fires, a predicate is satisfied, or any one of a set of events fires first — and check event existence without yielding.
API
Wait
Wait yields the calling coroutine until the named event fires once, then returns all arguments the event was fired with:
local player, killer = Bridge:Wait("playerDied")
print(player.Name, "was killed by", killer.Name)
WaitUntil
WaitUntil keeps yielding each time the event fires until the predicate returns a truthy value, then returns the arguments from that final fire:
-- Wait until a specific player dies
local player, killer = Bridge:WaitUntil("playerDied", function(p)
return p.Name == "TargetPlayer"
end)
print("TargetPlayer died, killer:", killer.Name)
WaitFirst
WaitFirst yields until any one of the listed events fires, then returns the name of the event that fired along with its arguments:
-- Yield until any round-ending event
local event, data = Bridge:WaitFirst({ "roundWon", "roundDraw", "roundTimeout" })
print("Round ended via:", event)
Return values
| Function | Returns |
|---|---|
Wait(event) | All arguments the event was fired with. |
WaitUntil(event, pred) | All arguments from the fire that satisfied the predicate. |
WaitFirst(events) | The event name that fired first, followed by its arguments. |
Has (non-yielding query)
Has returns immediately with a boolean — it does not yield. Use it to check whether any listeners are currently bound to an event name:
if Bridge:Has("playerDied") then
Bridge.Emit("playerDied", { player = player, killer = killer })
end
See also
← Bridge · On & Emit | register listeners and emit · Broadcast | server-to-client events · Listener | client-side event subscription