Server side verification for client side projectiles or raycast

How to verify client side projectile or raycast on the server to prevent exploits? But at the same time keep everything client sided for smoothness and no latency issues?

Any help appreciated!

2 Likes

Anyone have any idea how to do this?

2 Likes

Do another raycast on the server. That is the only way.

3 Likes

For this, you must make a function that will auto-solve whether the position is truly obtainable or not possible. A game that does a decent job of this is Phantom Forces; while they have an exploit issue, they have stopped people from simply firing the remote from anywhere. They trust the client to send the arguments but then check the sanity of those arguments on the server. Is the player position true? (ClientPos - ServerPos).Magnitude. How long was the bullet in the air? What’s the fire rate? After all that, you can replicate the shot if they all return true.

~ Sincerely, Ihaveash0rtname
“Happy Scripting!”

2 Likes

Can you elaborate on how to go about this?

1 Like

I’d recommend you making a module for your raycast and sending a table of information about the raycast to the server for verification and anticheat.

1 Like

Or you could use a remote function, but it would be cleaner for your raycasting in the future to modulize it.

What kind of verifications should I do?

1 Like

Do you have a zone where raycasts are allowed? Or ranges for the raycasts?

I haven’t started making anything yet, I’m just trying to understand everything before I start.

2 Likes

Ok, you probably want to have requirements for the rays. For example, create a zone, and check if the ray is within that zone, also give your raycast a length (direction*length) and check for those on the server.

1 Like

I’m not sure what you mean by this?

So by checking the players ray length with the server’s allowed length I can know if the player is exploiting?

Correct, and for zoning, you could find the raycast result instance and check if it’s within the zone using a formula or using this module ZonePlus v3.2.0 | Construct dynamic zones and effectively determine players and parts within their boundaries

if ((raycastResult.Instance.Position.(X,Y,Z) >= zone.Position.(X,Y,Z)-(zone.Size.(X,Y,Z)) then
    print("part in zone")
end
1 Like

I don’t understand what you mean by zone, I’m new to raycasts, my first gun system was using projectiles.

A zone could be a part covering the enter map, it could be invisible and you could check if the raycast is within that part/zone.

Oh I see, that could be helpful to make sure players stay in the map, my main problem though is with making sure players don’t exploit like shoot players around corners or across the map, change the amount of ammo and damage. Just not sure how to check for those things.

Could you raycast on the server and then send extra effects, such as bullets to the client?

I did that with my projectile system, but it has problems with one bullet hitting and other not.