TriggerEvent
triggerEvent
Triggers a custom event inside the current runtime.
Syntax
bool triggerEvent(string eventName, element sourceElement, ...)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
eventName |
string |
yes | The custom event name. |
sourceElement |
element |
yes | The source exposed to event handlers. |
... |
nil/bool/number/string |
yes | Optional event arguments. |
Returns
Returns true when the event is dispatched successfully; otherwise returns false.
Examples
Trigger a local resource event:
addEvent("round:started")
addEventHandler("round:started", root, function(roundNumber)
print("Round", roundNumber, "started")
end)
triggerEvent("round:started", root, 3)
Notes
- Available in both client-side and server-side resource scripts.
- Event arguments are limited to nil, boolean, number and string values.