I have a weapon system for Roblox. So, the problem is that anyone can call an “hit” event on any part and on any weapon they want (as you can see on the video), because everything simulates in the client.
My game is PvE. I use FastCast for realistic bullet trajectories and ByteNet for client-server communication. There’s going to be many players and enemies, so i don’t think it’s good idea to simulate everything on the server, but client simulation gives another problems:
As i said, client-server communication is defenseless against exploiters. They can kill any enemy they want (Not players tho)
Rocket simulations (As for RPGs or something) would be pretty strange to simulate on the client. Other players just can’t see the rocket, meaning there’s not that much “info” about world around player. (Or maybe that’s unnecesary, idk)
So, how i can protect my game against exploiters? (And if it’s possible to make optimized, how i can simulate projectiles for other players?)
There’s going to be a big map with many players and enemies. That’s means there’s going to be many raycasts per second (Because trajectory of bullets and projectiles is calculated by firing multiple raycast in a row with slight direction offset, depending on the acceleration). Client can handle this with ease, because client calculates only it’s own bullets, but server will suffer, because it will calculates EVERY bullet.
Send coordinates where you want to shoot from client, on server normalize this coordinates (Char.Position-ClientCords)(vector.normalize() or .Unit) and then fire a raycast based on that direction.
Essentially makes cordinates synced up and 100% safe.
You should simulate projectiles and their hits on the client. It makes the game feel much more responsive.
Any time you create a projectile or bullet, you should call a RemoteEvent which tells every other client to simulate that bullet for themselves (but just the visuals). When something is hit, the client responsible should report the hit and the server should perform a “close enough” sanity check and reject it if it fails. If it passes, than the server should assume that the client made the appropriate calculations and it did hit what the client says it hit, then you can create the effects.
That’s sounds pretty nice. I just don’t know how to do these sanity checks for bullets. Bullets and projectiles have some sort of an acceleration, which makes them drop at some distance after firing, so just firing a check raycast on server won’t work.
I think, for now i may send from client only the position of weapon’s muzzle and direction, and then, the server will detect what’s weapon the player is holding (So the exploiter can’t deal damage of weapon they not equipped) and do some checks for dealing damage. Still, there’s must be a sanity check on server, which i don’t really know how to do, as i said before. Thanks for help!