How to make non-laggy guns

(in terms of networking)

I haven’t touched guns on Roblox much until now. I’m trying to make a gun that is safe from too much exploiting but isn’t completely unbearable to use if the player has high ping. How would I go about making guns responsive and like they’re doing damage but not give the client full control over what they’re able to damage?


Remove models with a lot of parts and make them one part using model creating programs, and make sure there are no script errors in your game or gun scripts.

1 Like

Sorry, I wasn’t clear in my original post. I meant in terms of networking.

In terms of networking there are no Anti-Lag scripts that work its just going to have to be something that has to do with what network roblox runs on.

As is said about exploiting, never trust the client.
You could make the damage happen over a server script by placing the script in the bullets and checking in the server rather than on the client.

1 Like

I’m not sure having individual bullet objects is the best idea for guns. I’ve heard raycasting is one of, if not, the best way of hit detection for guns. But anyways, what would the general outline of the system be like? Having a remote event for shooting the gun is a bad idea because if the player has 500 ping it would take half a second before the player actually shoots, which is just unbearable. So what would you recommend to reduce delay from the player’s inputs while still not trusting the client?

1 Like

I’m honestly not too sure how you could make a gun work without using remote events?
You could try something called part caching (a plugin/module), which might reduce the lag of cloning and destroy parts.

Well, of course it would use RemoteEvents, I’m just asking about how you would make it look not laggy while still handling everything with a delay on the server. For example: if you were to pick up an item, have the client pick it up right when there is input but have the server do some checks then show the other players that the person picked the item up. In terms of a gun, I would worry about the client projectile getting desynced with the server and creating a “hey I shot here but that’s not where the bullet went” kinda thing.

In my game, all gun effects are client-sided. This gives me the advantage of say, having the gun firing instantly for the players.

Although right now my remotes aren’t the safest possible when it comes to exploitability, so far I haven’t seen anyone exploit (nor have I heard of any news about it). This might be a good starting point for a new game.

What I do is that instead of passing the player the person hit, and where they hit, instead I end up passing the actual local-sided ray. Once the ray is done, locally make the effects for the person, server side checks then if its clear, fire the gun effects for each other person in game.

1 Like

I’m using FastCast for my guns. Do you have idea how I would go about that with what you said while using the module?

Thats a hard question I think already big companies trying that getting keys from client and moving characters from other clients would be useful as an example if there is 5 players in one server server amount will be 5+1 and her client will post same number to other clients and everyones client generates 6 players I mean with basic informations you can give a server sided game effect but everything will be server sided and this all reduces lag like you can try messaging service to do that, foreverHD made infinite servers before you can try it, it will reduce lag I think but im not sure about guns they can broke but still you can fix it with some basic edits

Sorry, I didn’t catch what you were trying to say there. Do you mind rephrasing that?

I mean get basic information from other clients and animate everything from your own client like a movie

So your recommendation is to run all the gun’s VFX on the clients and have the server tell each client to display what’s going on?

Yes thats all I want to say if you do that this will reduce lag

1 Like

Sorry about my bad grammar I have so much bad grammar

So, just in general so somebody can confirm, the best way of going about this is to make the bullet shoot with sounds and animation on the client and then have the server calculate the damage right as it gets a request from the client to shoot?

did you found something? I would like to know

Let me ask you this, have you ever played a multiplayer FPS game where your shots have always landed? You’ve never been killed through cover? I don’t think there is really a way, it’s just as much faking as you can.

1 Like

Basically what I ended up doing is having the client show effects like sounds for the gun shooting and visual indications (animation and particles) on the client side as soon as they shoot. Meanwhile it fires a remote to the server saying where to shoot. When the message gets to the server, I do the raycasting and create a fake bullet model to look like the gun is shooting. Along with that, I play any sounds for everybody else besides the client who shot. This ends up creating a system where the actual raycasting and hit detection is at a delay, but the visual indications aren’t, so it ends up looking like there isn’t too much ping between the client and server.

Of course this system still starts to show its weaknesses when the player’s ping is pretty high. They’ll often miss their shots too. There isn’t a simple solution to this, but for the majority of the players connecting to servers where they have a good ping, it should generally be fine.

1 Like