Would having players mass use one server-sided script lag the server?

I have a lot of guns in my game, and am considering transferring all their server-sided actions to one script(currently each tool has its own script for handling the guns)

My question is that if I have all the players use one script in serverscriptservice for when they shoot,reload, etc a gun, would having that many players using one script so much lag the server?

IMPORTANT: To better shed light on the situation, at any given time there will most likely be 10 people firing a weapon(big server). Would having this many people connect to one script lag the server at all? Or would it be more optimal to have one universal gun script handling every players gun usage, than instead of having 10 unique server scripts in each gun handling the code to use the weapon?

Or is Roblox capable of handling that with no issue?

1 Like

i dont think it would lag too much, it will be better than each player needing to load hundreds of scripts for guns.

Hmmm, yeah just a bit worried, but that might be the best bet. Going to see what others think of the matter as well, thank you for your insight, it’s really appreciated.

If the script isn’t too crazy like several thousand lines, then you should be ok.

It’s probably way easier to manage and way more performant if you have just 1 server-script handling it instead of 10.

Hi there!

I think it would be easier to optimize and manage just one script, it should not cause any sort of lag if the script is well optimized and doesn’t just spam random stuff.

— p.s this is my first devforum reply, wish me luck! :smiley:

There’s almost no difference. Do whichever is easier for you to maintain. More info: Does increasing the physical number of scripts affect performance? - #5 by nicemike40

I see, interesting.

So what I was planning on doing is cutting down on the numbers of connections as well.

Right now each gun has its own unique script with around 10 or so connections, so compound that with around 30 guns, that creates a lot of connections for the server(300)

Would it be more optimal and better on performance to create a universal script that only has 10 connections that are universal and can communicate with every gun? Just wanting to get another opinion on it, because I’m fairly certain it would help, but not 100% sure. Others insight are extremely helpful.

I 100% recommend making a module script with all the shooting and reloading stuff in it and then requiring it from a server script in the gun. It works great, is easily editable and doesn’t lag at all even on bad devices!

When you say “connections”, do you mean remotes?

Because roblox will multiplex remote calls. In other words, 100 remotes will probably share the same TCP connection anyways.

So I doubt having more or less remotes would actually change much performance-wise.

The only differences would be:

  • more remotes means more stuff that has to be replicated, which could technically increase loading times by a negligible amount
  • a single remote would require you to pass an additional parameter to select a particular gun, which could increase network traffic (again it’s probably negligible)

I doubt either of those effects would really be measurable so again, do what makes sense to you.