Skip to main content

Events

Each round owns a RoundEventBus. Phases, win conditions, and game code use it to communicate without direct dependencies.

Connecting and firing

Use Context to subscribe to or fire events:

context:Connect("PlayerScored", function(player, amount)
print(player.Name, "scored", amount)
end)

context:Fire("PlayerScored", somePlayer, 10)

Connections created with context:Connect() are tied to the active phase. They are disconnected automatically when the phase exits.

To create a connection that persists across multiple phases, connect directly to the event bus:

manager.EventBus:Connect("PlayerScored", function(player, amount)
print(player.Name, "scored", amount)
end)

Connections made directly to RoundEventBus are not managed automatically and must be disconnected manually.

Built-in events

RoundKit fires the following events automatically.

EventArgumentsDescription
OnPhaseChangedoldPhase, newPhaseFired after a phase transition completes.
OnWinConditionMetoutcomeFired when a win condition returns a WinOutcome.
OnPlayerJoinedcontext, playerFired when a player joins the round without existing state.
OnPlayerLeftplayer, stateFired when a tracked player leaves. state may be nil.
OnRoundResetNoneFired by ClearRoundState() and Reset().

Custom events

Custom event names may be used for game-specific behavior.

context:Fire("BombPlanted", site)
context:Fire("RoundOvertimeStarted")

Use events when multiple systems need to react to the same occurrence, such as gameplay, UI, analytics, or effects. If only one system needs the information, a direct function call is usually simpler.


This concludes the core concepts of RoundKit. For additional patterns, see the full API reference.