it uses a for i loop with a total of 30 loops, 15 of which creates a ray to detect a hit (as a touched function is severely unreliable in this case). I heard that rays are already heavy on the server, but the server also has to clone a mesh, which is then tweened to create the rapid punching effect as seen in the gif. For the best performance possible, should I instead use FireAllClients in the loop which sends to all the clients the punching players PrimaryPart CFrame and create a shockwave tween effect on their own client side script?
For sure, visual effects like that should be handled on the client, to make the animations seem smoother. Raycasting (for hit detection) however should be handled on the server, and is not too intensive at all even if you’re firing multiple rays per frame you should be fine.
If I were in your situation I would first verify from the client that is initiating the attack that they can do so, then handle hit detection on the server and then FireAllClients and pass in the Character’s HumanoidRootPart (because they may rotate/move during the attack). Using this HumRoot you can then instantiate (locally) the meshes and tween them forward.
I see, I’m just a little confused by what you mean by hit detection on the server, do you mean the creation of the ray to be done on the server? Or for the client to create the ray and then pass to the server (of course this would be exploitable).
But with your idea, I could try:
Firing player > server creates multiple rays in a loop > in each loop FireAllClients(HumRootPart) > create visual stuff on the client side.
I’d recommend you raycast from the server. And your idea of trying that sounds great. You should definitely see an improvement over your current version.