What is the best way to make an automatic-gun server sided without lagging the game?

Hello. I am looking for a way to make an automatic server sided gun without lagging the entire game firing lots of remote events. I tried lot of things but they did not work. Does any of you have any ideas?
Any comment is appreciated. :+1:

3 Likes

Which things, specifically?

1 Like

Handling your guns completely on the Server, is really going to kill performance.
The reason being, you would have to fire a remote event from the client, every time a player makes a input. This would mean way more to process for the Server.

Performing every single effect, Raycast, and check on the Server is a extremely bad practice in itself. It’s just too much for the server to take, if you don’t run checks on the client first. This is especially true, if you have more than 5 players in your game.

I recommend using a client script to Raycast originally, only firing the server to shoot if a bit is connected. This ensures the Server does not need to do more than it needs to.

3 Likes

I set a variable of mouse down and I used a while loop waiting 0.08 seconds each time to see if the value is true, and if so it will just fire the bullet. But, I can not access the player’s mouse from a Server Script. I succesfully made a client-sided automatic gun but not a server-sided and it is a relevant issue to quality.

That is the exact issue I am looking to solve.

The best solution, is just not to do it at all. Use both the client and server, as it will greatly balance out the work load.

What is the reason you are looking to use only the Server? If you are worried about exploits, than you would be happy to know that you can prevent most exploits, by performing server sanity checks, as I mentioned in my post above.

1 Like

I am worried that it will effect the quality of the game.

That didn’t make a lot of sense to me, but you don’t need to constantly loop like that. Use RemoteEvents to trigger things on the client from the server and vice-versa.

1 Like

Can you elaborate on this? Using the client to handle effects first, will actually greatly increase the quality of your game, as it will minimize the shot delay to almost nothing for the local player.

I still don’t understand the point of a solely Server sided gun.

1 Like

This is the way that I use, referencing to a cool scripter

1 Like

Well, as I reminded it’s automatic, I am just going to lag the whole server if I will fire a remote event each time.

It is client sided. I am looking to make a server sided one. Do you have any ideas of making it without lagging the whole server?

I’ve seen it used in some games like Jailbreak. I do not really know how they made it server-sided (the bullets) without lagging the entire server using remote events (it’s automatic).

You’re lagging the server with a loop. A few remote event invocations a second won’t hurt things. If you have a value that’s replicated from the server to the client, you’re going to have the network lag anyways, plus the busy loop.

1 Like

Imagine firing 30 remote events in less than 5 seconds. And the loop I am using is client-sided. And when I tested my client-sided automatic gun it did not really effect my network or lagged my game.

I’m sure Jailbreak, and any of the popular games involving shooting for that matter, don’t stick completely to using only the Server. I am almost certain they process the shot on the client first, before attempting to do checks and inflict damage.

Now the visible bullets are a different story. Keep in mind that it’s not firing the remotes themselves that causes lag, but what happens when the request is received. As long as you build your bullets right, you shouldn’t have that many lag problems. 30 bullets a second is a little excessive though.

4 Likes

I am just going to leave this idea of server-sided bullets. Thanks everybody for your answers! :+1:

I ran into that issue as well, roblox servers aren’t powerful enough to hold a in game complex gun script.

1 Like

I would try it out, and experiment with it. If performance is fine, leave it, otherwise make due without it.

Also, remember that it’s only the visual effect of the bullets you are replicating on every shot. The damage should be done separately, so that the Server only does with sanity checks, if the detects a hit first.

2 Likes

I do plan to make the damage server-sided, but I want also the bullets to be server-sided I am worried it will effect the quality of the game. Nowadays, most Roblox games have very high quality so players are only playing high-quality games.