RBXEvent is a simple & lightweight custom event library that allows you to create, fire, connect to & disconnect from custom events created by yourself. It is intended to replicate the style of the built-in RBXScriptSignal datatype. It allows for same-sided messaging (server-server & client-client only) between multiple scripts, without the use of BindableEvents.
Get the library and use it in game: RBXEvent - Roblox
The documentation details the method by which RBXEvent can be utilized within your game.
To use RBXEvent, import it into your game via the link provided and place it into ReplicatedStorage.
Once you have imported the model into your game, you can begin working with the library.
To require the library:
local RBXEvent = require(game:GetService("ReplicatedStorage").RBXEvent)
To create a new event, simply use
local Event = RBXEvent.new()
where you can then
:Connect() a listener(s) to the events:
local listener = Event:Connect(function(arg1) print("The event was just fired with a parameter: "..arg1) end)
Then you can simply fire the event:
and the listener function will be called.
Keep in mind you are able to use a variable number of parameters, whether that is none, 1, or more.
The RBXEvent.new() method creates a new event and returns it.
Event:Fire(arg1, arg2, arg3, …)
The Event:Fire() method fires the event and all attached listeners (and causes Event:Wait() to stop yielding).
The Event:Connect() method connects the event to a callback function. The callback function accepts the arguments that were passed to Event:Fire().
This Event:Wait() method yields the thread until the event that the method is being called upon is fired.
The EventListener:Disconnect() method disconnects the EventListener from receiving further updates from the Event.
You may also take a look at the place-file if you are having trouble with the documentation:
RBXEvent.rbxl (23.3 KB)
It is recommended that you store your events in ModuleScripts so that you can bind to them & fire them from anywhere within your game. You are able to have multiple listeners in one or more scripts.
Of course you can create, listen to, and fire events from within only one script, however that defeats the purpose of this library.
Thank you for reading about my event library, RBXEvent! This is my first community resource that I have published (due to personal need for this in my own project), so it would be greatly appreciated if there are any thoughts, features, or concerns you may have about my library.
I hope that you can find a use for my library in one of your games or projects, and let me know if you do!
The library is linked below.
Library link: RBXEvent - Roblox