How to keep firing this event efficient?

Hello! This is my first post so please excuse me if i’m doing anything wrong and please let me know,

Anyways, I am currently trying to make a combat tool but instead of making it where .Touched is handled on the server I am having .Touched handled on the client simply because it is way more responsive.

The only data it sends is 1. The enemy position, 2. The name of the character model, and 3. the current arm it is punching with. Once the server receives the data it does a sanity check by doing the .magnitude and subtracting the two values. If the subtracted value is lower than the leniency then it will pass and apply damage. If it is higher due to the client teleporting all players close to themselves or if they have really high ping it doesn’t do anything.

This works perfectly fine with normal punching but, once it comes to a special barrage move I made I started to worry. Since it uses the same .Touched as the normal punching it would fire every time it punched a player. This is a problem because the barrage animation is very fast to begin with and can also be scaled with the agility stat.

What I am trying to accomplish is keeping the script from consuming the bandwidth of the client and keeping it efficient. I don’t want it to lag the server either. Please suggest some ways I could fix this! The only way I could is to sacrifice the smoothness and responsiveness :frowning: but I don’t want to do that.


I’d highly recommend just handling .Touched on the server. If it’s good enough for the default linked swords, which hundreds of thousands of people have used without issue, then I’d say it’s good enough for whatever you’re doing. It’s also much more secure.

I have thought of doing that it’s just .Touched isn’t really great on the server as it ALWAYS has a darn delay.
But if I have no other options ill do that.

There really shouldn’t be too much of a delay unless you’ve got REALLY bad internet, or something in your code is slowing it down. How often is there a noticeable delay with linked swords?

That’s true maybe this would be different because its up close and melee. Projectiles on the other hand do lag on server. They stutter and once they touch something it takes at least like .3 seconds for it to register and delete itself.

Ill try it.

Swords are up close and melee? I can’t really say anything about projectiles though, because I haven’t done anything with projectiles before.