I personally like using physics with touch events
I have a video showing how to calculate the force needed to make a part move to a target
And here is a little demo
BulletDemo.rbxl (36.8 KB)
to validate a hit is very difficult let me try to explain why
lets say there are 2 players player A
and player B
and lets say it takes 1 seconds for the players to send there characters position to the server and it also takes 1 second for the server to send that position to other players
so player A
moves from position 0, 0, 0
to 0, 0, 16
then sends this position to the server after 1 second the server gets the message and then sends this position to all other players so after a total of 2 seconds player B
gets to see player A
move from position 0, 0, 0
to 0, 0, 16
but by the time 2 seconds has past player A
has already moved to 0, 0, 48
so what this is explain is that player B
is seeing where player A
was 2 seconds in the past
and the server is seeing where player A
was 1 second in the past
and the same is true the other way around player A
is seeing where player B
was 2 seconds in the past
so when player A
shoots a projectile and hits player B
the projectile is not really hitting player B
its hitting where player B
was 2 seconds in the past and to player B
it might look like the projectile never hit and missed
and if the server does a check to see if the projectile really hit the server might thing the hit missed because there not taking into consideration that player A
is seeing player B
2 seconds in the past
now a difficult way to do this is for the server to keep track of the players position history lets say the server remembers the players positions up to 5 seconds in the past then when player A
hits player B
the server can check based on where player B
was 2 seconds in the past and this check would be more accurate but not 100% accurate
the reason its still not 100% accurate is because up until now we have assumed it take exactly 1 second for the data to be send from the player to the server while the real time it takes is variable meaning is constantly changing
we can use GetNetworkPing to see how long it takes but this is also not 100% accurate because events are not sent every frame to the server
if we look here Task Scheduler | Roblox Creator Documentation
we can see that outgoing property updates and events does not happen every frame
so what this means is if a player shoots a projectile closer to a send job then the information will get to the server quicker and if they shoot a projectile just after the previous send job then it will take longer for that information to get sent to the server
I don’t have a good answer for you unfortunately if we make projectiles be handled 100% by the server then it will feel unresponsive and inaccurate to the shooter and the player getting shot
if we make the projectile handled by the shooter then it will feel responsive and accurate to the shooter but will be inaccurate to the server and the player getting shot
this is the reason why tab targeting is a common method of doing fighting in online games
so if your going to make projectiles be handles by the client the best the server can do is guess ruffle the area where the projectile hit
you might also want to make each player handle the projectiles separately so that when player A
hits player B
on the hand the server sends a event to player B
saying player A
hit you on the hand then player B
will make a completely different projectile that looks like it hit there hand to them
if you make projectiles like in the video i sent above you might need to know where a projectile was along the path so here is a demo on how to do that
Projectile_Path.rbxl (35.4 KB)
if you have a anti hack to stop players from teleporting but you have a skill that teleports a player then you will need to send a event to the server and the server would need to validate the skill and then teleport them forward bypassing the anti hack