How do I organise client-sided projectiles?

Ok. I got a local script and a server script.

Player clicks > local script fires and creates bullet.
Sends info to server.

Server receives info. > creates their own bullet to.

Client bullet hits something > sends to server

server receives info that client bullet hit > does some sanity checks to check if the bullet really hit something

The problem: What if there were 2 bullets flying in the air? what if the second bullet hit first and made the server think the first bullet hit? How do I organise and tell the server which bullet actually hit?
How do I do a sanity check on which bullet hit? (If its possible!)

Do this:

  • Client clicks and the client validates if they can shoot
  • If the client validation passed, then the client shoots a cosmetic only bullet
  • The client at the same time passes the information along to the server (position and direction)
  • The server does validation then calculates the shot aswell (Could create it’s own projectile)
  • The server fires a remote event to all client except for the one who shot the bullet
  • All the client pick up on the remote event and create their bullet with the servers data

The benefits of this is this:

  • For a non-exploiter
    Their client side validation will work and everything works with no delay, this means that there is no need to go to the server and back to check if they can shoot

  • For an exploiter
    They may fool their client side validation, so they will see a shot, but the server side validation will deny them, so all the other clients wont see anything

3 Likes

Ok. But how would the client tell the server which bullet hit?

You don’t. The server shoots it’s own projectile (This is much easier using fastcast).

1 Like