What's the purpose of Bindable Events/Functions?

Hello Developers! :wave:

I have a problem figuring out what’s the use for Bindable events/functions? Is it like module scripts where you can use a it in a local or server script? If so, which is better, module script or bindable functions/events? Any response is appreciated! :grinning:

Bindable events are used for server to server communication.

1 Like

RemoteEvents can be used to communicate between the server and the client
BindableEvents can be used to communicate between the server and the server or the client and the client.

An alternative is to use the global table (_G).

Essentially, if you want to transfer information between two scripts, use BindableEvents.

A bindable is exactly like a remote event except that it cannot cross the client-server boundary.

You can use a bindable to communicate between local scripts or between server scripts, but not between local scripts and server scripts.

They’re especially useful when you need to pass data from one script to another, or use event-based programming for some use-cases where you want the server or the client to respond when an event is triggered.

2 Likes

Using the global table is not really comparable to using bindables though. It’s not immediately implied that you’re looking to use a global scope when using bindables. Both the global table and bindables have different purposes and they can’t always be used in place of eachother.

Can’t you just use a model script? And why in the world would I want to communicate server script to server script and vice versa??? I can just use one script instead.

You can use a module script in place of bindables most of the time, but bindables are convenient and pretty nifty in certain scenarios.

Bindables are mainly used as a trigger for something to happen. For example, consider a game with a round based system. The end of the round can be marked by the triggering of a bindable event. That way, any scripts that are relevant to the round system can listen on this event and perform some action when the round ends. That’s just one example where it’s convenient to use a bindable. You can likely find a way to use a module script to fulfill the same purpose, or by consolidating multiple scripts into one, but I find bindables an elegant solution to use event-based programming within one level of the client-server model.

1 Like