Best way to handle Events?

Long story short,

I’m making a game in 24 hours for the sake of my fun. I really don’t know how or when I should use my remote events and bindable events. The server takes the event’s name into an argument. Then it runs a function by the event name.

  • I use one remote event and one bindable event
Good Example Code
local Event ="BindableEvent",workspace)

script.Name = 'ExampleEventSystem'

	if EventName == 'Hotdog' then
		print('Hotdogs are disgusting with bread')
		EventName == 'Pizza' then
		print('Pizza is disgusting with bread')
		EventName == nil then
		print('nil is disgusting with bread')


-- Server Script Please
Example Code Output
nil is disgusting with bread (x2)
Pizza is disgusting with bread
Hotdogs are disgusting with bread

Any feedback or helpful tips are appreciated :slight_smile:

Edit : I know how to use bindables and remotes. I’m asking if I should use only one of each or not. Check the examples.

1 Like

So the way I think most people use events is for cross script communication.

Bindable events are for scripts of the same type (server to server, local to local)
Ex. You can have one script that fires the event and another who receives it

Remote events can be used between server and client


Remotes are used for cross server-client communication and vice versa whereas bindables are used for cross script (within the same environment i.e client or server) communication.

Remote example:
Let’s say you want to make a shop. On the client, you could make a GUI with shop items. When the player clicks on an item, the client checks if the player has enough currency to buy the item and if the client doesn’t, it gives the client an error through a GUI but if it does, you can then fire the server requesting to buy the item. On the server, you would check if the player has enough currency and if they do, give them the item but if they don’t, then that’s an invalid remote call and you can punish the client i.e ban them for potentially exploiting. You can learn more about them here.

Bindable example:
I don’t use bindableevents so I can’t really think of an example but you can create your own events and fire them from multiple scripts within the same environment.

You can learn more about them here and remember to always add checks to make sure the client meets the conditions to be able to fire the remote on the server.

Hope this helps you understand remotes and bindables better and good luck with your game! :slight_smile:

1 Like

Both RemoteEvents are used to cross the client-server boundary, bindable events are used to communicated without crossing any client-server boundary.

A RemoteEvent can be used to send information from a client to a server via FireServer(), or it can be used to send information from the server to the client via FireClient(). When sending information from the server to the client, it also has a useful feature of FireAllClients() which will fire any clients linked to the remoteevent being activated.

For an example; say a player buys a tool from a shop, and for safety you keep those tools in ServerStorage. Since the client can’t access ServerStorage, you send the information to a “Middleman” in the form of a RemoteEvent. This RemoteEvent is triggered, which a script is fired to give the player the tools from ServerStorage.

Bindable Events are used when not crossing a client/server boundary, you can use them either when communicating between two (or more) local scripts or server scripts. As oppose to using things like :FireClient() and :FireServer() you just use :Fire().

For example; Let’s say you are trying to set up a GUI Timer, and as opposed to activating each local script individually to activate separate things in different GUIs, you have it set up to a bindable event in order to activate them at the same time (also useful for sending data to complete different functions between two local/server scripts).

Hope this at least gives you a small understanding of the differences.

1 Like