Custom Lua Events!

Hello!

This post is old and I was newer to programming at the time. There are much better modules out there like LemonSignal. Best of Luck!

Original Post

Hello programmers!

I’ve decided to make a module that allows you to create your own events!

All you have to do is follow these steps:

  1. Require the module and store it in a variable named “Events”.

  2. Make a new variable and set it to Events.new()

  3. Call :Connect() to make a connection to your event.

  4. Call :Invoke(…) on your event to invoke it.

Disconnect your connection by calling :Disconnect() on your connection to avoid memory leaks.

You can get the module here.

2 Likes

Sorry to be that guy, but you can already use bindableevents.

3 Likes

Oh yeah. Dang it! I made this for no reason :confused:

1 Like

Well, the only good thing in the module is :disconnect() so uh you didn’t make this for no reason

2 Likes

When you connect a event, it returns a RBXScriptConnection which has a :Disconnect() function already

3 Likes

While this is true, it is important to remember that it is an instance. So depending on the implementation of the OP it may be better on memory and faster when executing.

4 Likes

I can’t view source code right now, so I’ll check later.

That seems like a good time! It’s nice that you can create an event that will fire whenever a specific data value changes.

1 Like

If you’re referring to local values, then yeah it’s darn good for that, but if you’re referring to attributes, value objects, etc, then you can already do that without this.

2 Likes