π© Events
Subscribe for user-defined Events
info
Static Functionsβ
Returns | Name | Description | |
---|---|---|---|
![]() | Call | Calls an Event which will be triggered in all Local Packages | |
CallRemote | Calls an Event if on Client which will be triggered in all Server Packages | ||
CallRemote | Calls an Event if on Server which will be triggered in all Client's Packages of a specific Player | ||
BroadcastRemote | Calls an Event on Server which will be triggered in all Client's Packages | ||
![]() | function | Subscribe | Subscribes for an user-created event which will be triggered for both local or remote* called events |
![]() | Unsubscribe | Unsubscribes from all subscribed events in this Package with that event name, optionally passing the function to unsubscribe only that callback |
info
Remote* means the other side, e.g.: if Iβm the Client, the remote is the Server. If Iβm the Server, the remote is the Client.
Call
β
Calls an Event which will be triggered in all Local Packages
Events.Call(event_name, args...)
Type | Parameter | Description |
---|---|---|
string | event_name | The Event Name to trigger the event |
any | args... | Arguments to pass to the event |

CallRemote
β
Calls an Event on Client which will be triggered in all Server Packages
Events.CallRemote(event_name, args...)
Type | Parameter | Description |
---|---|---|
string | event_name | The Event Name to trigger the event |
any | args... | Arguments to pass to the event |

CallRemote
β
Calls an Event on Server which will be triggered in all Client's Packages of
Player
Events.CallRemote(event_name, player, args...)
Type | Parameter | Description |
---|---|---|
string | event_name | The Event Name to trigger the event |
Player | player | The remote player to send this event |
any | args... | Arguments to pass to the event |

BroadcastRemote
β
Calls an Event on Server which will be triggered in all Client's Packages
Events.BroadcastRemote(event_name, args...)
Type | Parameter | Description |
---|---|---|
string | event_name | The Event Name to trigger the event |
Player | player | The remote player to send this event |
any | args... | Arguments to pass to the event |
Subscribe
β
Subscribes for an user-created event which will be triggered for both local or remote called events
Returns the function callback itself
Events.Subscribe(event_name, function()
end)
Type | Parameter | Description |
---|---|---|
string | event_name | The Event Name to Subscribe for an event |
function | callback | The callback function to execute |
Unsubscribe
β
Unsubscribes from all subscribed events in this Package with that event name, optionally passing the function to unsubscribe only that callback
Events.Unsubscribe(event_name, callback)
Type | Parameter | Default Value | Description |
---|---|---|---|
string | event_name | The Event Name to Unsubscribe | |
function | callback | nil | The callback function to unsubscribe |
Examplesβ
-- register for a local Event (local = client only)
Events.Subscribe("MyLocalEvent", function(my_text)
Package.Log("Event received locally! " .. my_text)
-- outputs "Event received locally! hello nanos world!"
end)
-- calls a local Event in all Local Packages
Events.Call("MyLocalEvent", "hello nanos world!")
-- register for a server Event (remote = server)
Events.Subscribe("MyClientEvent", function(my_text)
Package.Log("Event received from server! " .. my_text)
-- outputs "Event received from server! hello nanos world!"
end)
-- calls a remote Event in all Server Packages
Events.CallRemote("MyServerEvent", "hello nanos world!")
info
On Server, registering for remote events has an addition parameter: Player, which is the client who sent the event.
-- register for a local Event (local = server only)
Events.Subscribe("MyLocalEvent", function(my_text)
Package.Log("Event received locally! " .. my_text)
-- outputs "Event received locally! hello nanos world!"
end)
-- calls a local Event in all Local Packages
Events.Call("MyLocalEvent", "hello nanos world!")
-- register for a client Event (remote = client)
Events.Subscribe("MyServerEvent", function(player, my_text)
Package.Log(player:GetName() .. " sent an event from client! " .. my_text)
-- outputs "Syed sent an event from client! hello nanos world!"
-- sends an "answer" to the player which sent this event
Events.CallRemote("MyClientEvent", player, "hello nanos world! message only for you!")
end)
-- sends a remote Event to all Players in all Client Packages
Events.BroadcastRemote("MyClientEvent", "hello nanos world!")
Passing entities through Eventsβ
-- register for an Event (remote or local)
Events.Subscribe("MyAnotherEvent", function(my_text, my_vector, my_character, my_number)
Package.Log("Event received! " .. my_text .. " " .. my_vector.X .. " " .. my_character:GetViewMode() .. " " .. my_number)
-- outputs "Event received! hello nanos world! 123 1 456"
end)
-- passing Characters through events
local my_temp_character = Character()
-- calls a local Event in all Local Packages
Events.Call("MyEvent", "hello nanos world!", Vector(123, 123, 123), my_temp_character, 456)
-- calls a remote Event in all Server Packages
Events.CallRemote("MyEvent", "hello nanos world!", Vector(123, 123, 123), my_temp_character, 456)