Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How many Remote Events should you have?

Asked by 6 years ago

I have currently just one remote event under the the replicated storage and it handles all my events when it comes to things like purchases from the shop. I also have one remote event under each tool I add to my game. I see a lot of people use remote events in different ways. Some use many for each buy event and other even put them under different places like workspace. Is one remote event enough for handling all the purchases in game? How does it affect loading to have more than one? Ultimately what is the best practice when dealing with remote events?

0
1 event for a shop system is a perfect amount. Keep separate tasks under separate events so they don't confuse you. lukeb50 631 — 6y
0
Lukeb50 is correct. Having different events means you don't have to check parameters. For more info, see https://forum.scriptinghelpers.org/topic/112/how-to-use-remoteevents-properly https://forum.scriptinghelpers.org/topic/112/how-to-use-remoteevents-properly hiimgoodpack 2009 — 6y
0
So right now my remote event is the client sending a message to the server and then the server performs what ever it is scripted to do. When ever someone clicks the "buy" button in the shop I have an on server event fire where the client tells the main server script hey I want to buy this, then the server handles the rest. I have been doing this for all my shop purchases. Zeustice 41 — 6y
0
From what it sounds like I am doing it correctly then? Zeustice 41 — 6y
View all comments (3 more)
0
Remember, with all of your scripts knowledge, can you exploit your game with a localscript? If you can, you have something wrong with your remotes. If not, then yay! hiimgoodpack 2009 — 6y
0
Alright, sounds like a yay! For me. My local script only sends a message of an on server event and handles GUI elements. All main things like the event that was fired by the local script is handled by the server. The local script only sends a message and doesn't have any of the data. All the data is handled on a main script in server script storage. Zeustice 41 — 6y
0
This should probably be closed for "Matter of Opinion" CootKitty 311 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

"Some use many for each buy event and other even put them under different places like workspace."

This is just your choice of organization. If you can make do with only one RemoteEvent for all purchases, great! But if you find it easier to split it up into multiple RemoteEvents, that's perfectly fine too. Adding a RemoteEvent (or even 10s or 100s of them) to your place shouldn't impact performance in any noticeable way. A RemoteEvent should take significantly less time than a Part to load, and shouldn't impact performance once its loaded (unlike Parts, which impact collision, physics, and graphics, depending on if you're looking at the server or the client).

Note that if you wanted, you could make do with a single RemoteEvent (though I do not recommend this). ex, if you have a LevelFinished(levelNum) and a PurchaseItem(itemID) event, you could merge them into a generic Event(eventID, eventData). On the server, you would need a dictionary mapping an eventID to the function that can handle it. This is a lot of extra work (for both you and the server) compared to just making separate RemoteEvents!

On the other hand, if you're thinking of making 10s or 100s of RemoteEvents that aren't going to be used by all players (just a few of them), I would recommend considering simplifying them.

"Ultimately what is the best practice when dealing with remote events?"

In terms of count, do whatever makes sense (ie use as many as you need). More important than the number of events, however, is how secure they are. An exploiter/hacker has the ability to activate any RemoteEvent with any value they like - including ones you didn't intend. Check out this guide for more information and spend some time thinking about what happens if someone sends either subtly wrong or completely random arguments to your RemoteEvents/Functions. It may also be good to keep track of how many times any one player activates a RemoteEvent/Function and kick them if they're spamming it -- ex, if someone activates a RemoteEvent 600x/minute and you are sure that your scripts never activate it more than once per second (60x/min), you've found a hacker.

Ad

Answer this question