Remote Function Delay

Hey guys!

I created a gun, and it works perfectly well. Recoil, Raycasting, Ammo - everything works great!
Here is a demonstration of my gun at its current state:

I recently added a reload / ammo checking system, and a shot delay to prevent rapid spam. The problem is, I’m using remote functions to check these values, so that No Exploiters can Manipulate Changes made and returned in the Server.

The problem is, it causes a bit of delay between my clicking and the trajectory of the bullet.
Here are the RemoteFunctions and Code that I have currently:
image

PS: I was having trouble formatting the code on the forums, if anyone has a quick tutorial for that please help me.

Anyways, I’m wondering if there is a better way to communicate the ammo and able to shoot booleans from client to server, or if there is a way to fix delays in general. Thank you!

The remote function delay is there and can not be removen, this is one of most frequently asked questions.

1 Like

Delays are inherent when working with remotes because sent and received data needs to cross the network barrier from client to server or vice versa. In the case of RemoteFunctions, it’s a round trip to your server (wherever it’s being hosted) back to your machine.

If you want really effective results, handle the client and server as two different entities. The client should control a gun as if it was authoritative and everything should happen near instantaneously, while the server is more in charge of handling important tasks, verifying and then replicating changes as needed to other clients.

2 Likes

Is there a better way of handling the reload and ammo and shooting conditions?

From the video, I think that its ok.

1 Like

I see, currently I’m handing bullet trajectory and hits on client and having them checked and replicated throughout the rest of the clients. To avoid exploiters, I was convinced I needed to check and verify ammo and shot delay through the server? Should I be handing these on the client instead?

I wish I could show you the delay between my click and the shot, because you can’t see when I click my mouse in the video

Ok, so fire the projectile on client and send info to server, that will replicate it to other clients.

1 Like

YEP thats what I’ve been doing haha. The delay is when I check if I can shoot or not (depending on if I have ammo or not. Or if I’m reloading or not), and checking my reloading state through a remote function.

Yes, handle ammo on the client. If you need an extra layer of security, track ammo on the server as well. Don’t let the server damage any Humanoids if it’s ammo tracker is at 0, regardless of if your system determined that a valid hit was made or not.

1 Like

Fire it anyway (not anyway, but based on clients var) and give the damage (and replicate it) only when the player have amo

1 Like

Thanks so much for your help. Happy Holidays!

1 Like

Thanks so much for your help. Merry Christmas!

1 Like