I have a remote event that fires from the client, yet there is a delay. I would wonder how to fix that delay, as it is a gun system and a delay between clicking and shooting is not ideal.
I have no wait() or task.wait() inside of the shooting function.
Keep in mind there will always be some amount of delay between the client and server due to latency. As remote events fire from the client to server (or vice versa), there isn’t much you can do about the delay.
Of course, you could always simulate the bullet on the client side to make it show instantly for the shooter, and send the remote event to other players that still need to see the shooting (there will still be a delay between players)
You could “shoot” on the client, then simply send the results to the server. This would atleast appear to be faster (although if you’re really laggy others would be confused on how you hit them, and you might be picked up by anti-cheats)
This be more exploitable tho but like checking on the server should be enough
If you want things on the server, you will have to compromise with the latency. It’s unavoidable, the signal has to travel some distance to communicate
My solution: create visual bullet on client, send hit info to server, validate hit on server, draw bullet on other clients
But I don’t understand how I would get rid of the delay, would I have to make a raycast on the client to the mouse position and send its position to the server to create the bullet, therefor getting rid of the delay, while still using remote events?
So basically, creating a raycast on the client, then sending the results to the server.
To get rid of the visual delay, you would do a raycast on the client and show the bullet on the client. Then, you would send the event to the server (preferably with some server-side validating to make sure that the information that the client sent is real). The server would then send an event back to all other clients to simulate the bullet, so that other players can still see the bullet and so that the original player doesn’t see the bullet twice (This will be delayed, it is unavoidable). The server would also calculate who the bullet has hit and deal damage etc.