Best way to make raycast weapons uncheatable and performant?

So I basically want to make guns that show bullets, and damage when the bullets hit another player. I figured that raycast would be the best for this. Now my problem is I tried this

  • Clientside raycast - problem is player can just cheat
  • Serverside raycast - calculations are funky when moving, not performant
  • Client and Serverside(rendering client, shooting server) - the hitdetection is bad, I cant hit players when they move, jump etc. Its just hard

Now I have seen 2 games which had amazing gun systems I would love to implement in the same way: Gun Kit and Undead Defense Tycoon.
They are amazing and feel amazing.

So my question is can anyone tell me a good way to do this without having full cheater servers or windows internet explorer games? Thank you very much!

Cheaters suck at subtlety. Not only is it less fun, but it takes a lot more work to toe the line. You don’t need to be 100% thorough with cheat detection, just check once in a while if their behavior seems logical. If they’re being obvious, like 95%+ headshot rate across fifty kills, killing people through walls more often than they should or through multiple walls, making a consistent stream of spawnkills from halfway across the map.

How many hackers are going to make a headshot cheat that only functions on every third kill?

This way you don’t overload the server’s resources with endless security checks and you can avoid the discrepancy between server and client positions and aims.