Mass Firing of Events

  • What are you attempting to achieve?
    Basically, I am making an energy beam. Long story short wherever the player points its mouse the beam goes.

  • What is the issue?
    The player fires a lot of events of the position that the mouse in. For the beam to look good it fires an event maybe every 0.05 seconds. I believe this would cause client/server lag. However, I do not see an answer to solve this as I want my beam to look good and also not be laggy. My question is if this mass firing of remote events will cause lag and if it does what would be an alternate solution?

  • What solutions have you tried so far?
    Unfortunately, I do not see many solutions to this and maybe you guys will.

Help will be much appreciated.


You could make the beams locally every frame on the client so it looks smooth for the player, and then only update the server every 0.1 seconds and have the server make an extra beam in-between calls so that it looks smooth too.

Yes I can make it smooth for the players thank you for the suggestion. However, could you please clarify what you mean by “have the server make an extra beam in-between calls”.

In addition, isn’t firing a remote event every 0.1 seconds also a latency problem. I read that roblox can support a lot of remote events firing and I also read that it is not the best option to fire that many events.

1 Like

If the beam only looks good if you do it really fast then you can just make beams in the duration between the position updates to keep the appearance.

You could even interpolate or try and predict where the new position will be based on the previous positions and the direction they are moving.

Firing a RemoteEvent 10 times a second won’t cause issues.

1 Like

I wouldn’t suggest creating a server-sided beam at all unless there’s a reason it needs to be there. I would just fire positions to every client (excluding the beam user) and allow each individual client (including the beam user) to render the beam on their end.

Every client would get the benefit of a smoothly animated beam with the only bottleneck being when they receive the call from FireAllClients, which should be marginal. The server wouldn’t spend time creating a beam either.

1 Like

Yeah, this is true.

If you want to get the beam looking great on all the clients then the best way is to create it locally on the origin client, and then have the server relay the start and end position to the other clients and have those clients create it locally too.

You could update the beam more frequently on that particular client, and then send remote event calls less frequently to update the position. You can also use Lerp (Linear Interpolation) for other clients’ beams so that the infrequent position updates still make a smooth animation.

1 Like

That is exactly what I am doing.

For this I’d recommend…

  1. Handling the beam effect on the client. This includes the original player and all players viewing the effect. This will reduce the strain on the server and make your effect look a lot smoother.

  2. Firing only once or twice a second, instead of 20 times. As you mentioned, this is going to put some strain on the server, especially if lots of people are doing the effect all at once.

Here’s a rough kind of method of how you may achieve it…

  1. Have the beam update effect update normally on the client activating it

  2. Every 1/2 a second, fire all relavent information to the server. The server then verifies this information and fires to all other clients. You could also limit the players to send this data to based on their environment. For example, ignore players who are greater than 200 studs away from the sender as they will be unable to see him/her in the first place.

  3. On the clients who receive this data, use TweenService to update the sender’s beam info. By doing this, the sender’s beam will appear to move smoothly, despite only being updated twice a second.

Here’s an example of something similar I did for a laser-eyes command (receiver left and sender right):

Thank you, I think this will help my worries.
However, could you please clarify how I would use TweenService for the beam or the sentence you said “Update the senders beam info” because I am lost by that. Thank you.

I’m guessing for the beam you use a Beam attached between two parts (origin and end)? If so, when you receive the latest position from the server, do

TweenService:Create(beamPartEnd,, {CFrame =}):Play()

Instead of running the effect on the server, we’re going to fire the beam position and the player instance of the sender to all other players using a RemoteEvent. These players will then re-create the beam effect on their client for the person who activated the effect.

Yea I was originally sending from the original client to the server.
Then the server to all the other clients and they make the beam for themselves. Yes I am using the beam feature and I just tried your feature and I think it will work.
Thank you so much, just another quick clarification. So the person doing the beam we will make his beam high quality, for other players we will use the feature you just said.

Spot on, yep. You can update the beam 20+ times per second for the person activating the beam, whilst using the other method for everyone else.

Okay, thank you so much. This will work perfectly :slight_smile:

1 Like