Cause I fire the raycasy in the server script instead of local
It’s slower cause it relys on the server, I’m thinking of switching to do the raycast in the local script instead but I’m afraid of hackers with injections firing off 6billion events
Client detects the input (mouse click for example), do a local raycast for only visuals (muzzle flash, crosshair recoil, hitmarker, etc.) and then fire a RemoteEvent to the server with information about it: Raycast origin and direction (to make sure they are shooting from where they are at), weapon id, ammo count, etc.
You could even add a timestamp / tick count, and then check on the server whether they are shooting way too fast to be possible with whatever gun they have
Server is where you add your per player debounce and sanity checks:
Is the player holding that gun?
Do they have ammo?
Is their location correct?
Is the fire-rate correct?
If they pass all the checks, then you apply the damage and whatnot
It would better to check if the raycast COULD have hit the target rather than replicating the shot exactly. If an object on the server’s check gets in the way, or more likely, out of the way, it could lead to the shot being way off.