Wanting to optimize part movement on client, there is a delay at times

i am moving a ball on each client and registering hits on every client. if enough players have registered a hit on server i then set a new target. this works fairly well but at times there is a delay between setting a new target. am wondering if anyone has any suggestions for this.

for now i’ve created a new thread handling the function for every raycast in my raycasts table. i’ve also added a second check that if my raycasts were to fail i also check the distance. because just using distance also has not been very reliable. especially when the ball becomes very fast.

i’ve created a part on server as a fail safe and i’ve seen it used in testing only once. have not tested much. i believe the delay is due to latency and that if majority of players have a good connection then those players will not ever see the delay… i could be totally wrong about that.

what i’m thinking atm is that i could register the new target on the client… and then have the server confirm this to be true. so then there should not be a delay at that point. and if anyone is trying to exploit well it still wouldn’t work.

  1. because if a player is lagging it may take a bit for them to recieve the new target on the client, this would be a delay for them…
  2. if majority of players are lagging it may take a bit of time to register which would cuase a delay for all players.