Firing Delay in Firearm

Hey, so I’ve written up code for a firearm I made. And I’ve noticed there’s a small delay whenever I click to fire it. I’m guessing this delay is caused by the RemoteFunction firing the client to get the Mouse Hit and returning. I’m wondering if there’s a more efficient, delay-less, way of doing this.

2 Likes

Run all of it clientside but have the server routinely do security checks to ensure the client isn’t trying to fire when they shouldn’t be / in places, aiming at spots they shouldn’t be able to reach or see. The only thing serverside should be the server deciding if the bullet actually hit, and replicating that damage to the user they shot. The client should be doing hitmarkers and all that clientsided so there’s no delay in feedback and such.
(The downside is you may have the client thinking they’ve hit someone when they actually didn’t, and the effects play as though they have. That’s what people complain about in games like Call of Duty, getting hitmarkers but no actual results.)

You should be doing all visual and audible things on clientside so there’s no networking lag interrupting the experience while verifying things serverside.

7 Likes

You could do it the lazy way and do something like this when you’re going to fire a RemoteFunction/Event
Using a spawn.

--some code
spawn(function()
   --fire event in here
end)

--somemorecode

Now efficiency and performance wise, this probably isn’t a good thing to use but I wouldn’t be able to tell you why.

1 Like

Generally the client should assume its correct and carry out all the visual feedback.
The server should be receiving only the bits of information you need to verify and will verify it before any opposing client sees results

2 Likes