Should I use Bindable Events/Functions instead of Module Scripts?

Hello everyone! So I am trying to make a round based game and I’ve been looking at some round based open source games and I came across Roblox Battle 2018 Edition that was made by TheNexusAvenger and when I looked at the game, it uses bindables for global functions like for example in it’s PlayerManager script, it creates functions that are global and connects it on a BindableEvent/Function for it to be accessed by other scripts.

So my question is: Is this way better than just using module scripts? Also, are there any more good round based open source games?

Bindables predate modules, but modules however are much better for this kind of thing now. Bindables are still useful, don’t get me wrong, but modules are much better for reusing libraries of code in different scripts.

While I haven’t open sourced any games I do like making round-based games a lot, so you can always dm me for help.

1 Like

You could use Bindable Events to make a regular script into module scripts except it’s not exactly the expected use for the. Bindables a great when you need scripts to communicate between each other and less for making a code library as @sjr04 briefly mentioned.

To answer your question you should be using Module Scripts. They can execute on the client or server, are more fitting for the task, and will be easier for developers to understand if you ever need to debug the code.

1 Like

When it comes to script-to-script communication, ModuleScripts are best. If you define a function in a module, and call it from another script/module, you’ll always get the same data you sent. With a BindableEvent/BindableFunction (and RemoteEvent/RemoteFunction), data has to be serialized and deserialized. Not all data can do this - see the last code sample on BindableFunction:Invoke.

However, BindableEvent is extremely useful when using the Observer pattern (sometimes called Signals, or Event-Listener). Basically, for creating your own events, you can use a module like Signal in Nevermore by Quenty, which internally uses a BindableEvent. The class allow you to create your own events which act much like BindableEvents, minus the typical limitations.

As for BindableFunction… it’s almost always worse than just calling require on a ModuleScript and calling a function returned by it. The only time it’s better is when you want something simple, and even that is up for debate. There is no good reason you’d want to do this over a well-written ModuleScript.