September 20, 2022


Event:GetEvent(eventName, space)


Get the events in the specified space. In most cases, it is not necessary to specify the space. When it is not specified, it defaults to the space of the engine ("engine"), so there is no need to pass the second parameter when obtaining the events defined by the engine, that is, event:getevent ("someevent") is equivalent to event:getevent ("someevent", "engine"). In a few cases, the two systems may just share the same event name, but the trigger timing is different, so it needs to be distinguished by namespace. For example, the "jump" event of the level system is to skip the level, and the "jump" event of the AI system is to jump. If the event is not distinguished, the AI system will trigger the jump event, and the level will jump. When this happens, namespaces play a role. When AI system triggers events, it only gets events in its own space to trigger, and so does the level system.


Variable name Type Describe
eventName string Event name
space string Namespace

Return value

Type Describe
BindableEvent Bindable events

Code example

Bind the global event of player login and print player information.

local bindableEvent = Event:GetEvent("OnPlayerLogin")
    print("OnPlayerLogin", player)