How to make fast shooting towers without spamming remote event?

Today I am reworking my tower system and I want to reduce network usage and increase smoothness in shots, currently my system uses “fire remote event for each shot” but this becomes problematic when tower has fire rate of like 0.05s and now imagine that you multiple the amount of towers like this one by 100, now this is a recipe for overloading the network.

I think I might be able to solve this problem by telling clients when to start and stop shooting, but this makes my code a lot more complicated that what it was.

Is this a good solution to this problem? If not then what’s a better one?

Also please note that I do not want to compromise security for this.

1 Like

Only solution I can think of is what you already suggested. Have a StartShooting remote and a StopShooting remote. It’ll cut down on NetworkUsage insanely.

You can still perform sanity checks with this method by checking if the tower system is still alive, etc. Every second the StartShooting remote is still active, check as many exploitable loopholes as possible and if something is fishy (like the tower got removed but the StopShooting remote was never called) then just end the StartShooting loop.

2 Likes

Toggling the shooting as the above post suggested is likely the best way to tackle this problem. However this solution brings up another potential problem, what if the user attempts to spam toggle the firing thus resulting in the RemoteEvent being “spammed”? You could solve this by adding a debounce to the RemoteEvent being used to fire the server.

1 Like

Hopefully: Don’t Remote this.

At first couldn’t figure, why tower AI; would be Remoting at all…

Went to your Page; realized that this was for a Tower Defense game; but still don’t know why towers, which are shooting zombies, would ever need to Remote after being placed…

Still confused.

Because they need to deal damage to the enemies? This cannot be solved locally as it won’t replicate to other players and the server itself as well, and relaying on client with dealing damage would be huge security compromise that would allow exploiters to kill all enemies with one simple script.

Server controls the towers, server does minimum work as telling the client when to start and stop shooting including managing upgrades and toggling animations. So I don’t see need for debounce for my use case.

Um… still don’t see why the client Remote would be involved…

And, a debounce might help, if it intercepts the Remote call; then prevents it: Remember, you are trying to optimize here…

You would have to show your code, for me to grasp the sit…

How do you expect me to inform connected clients to see the visual effects then?

Adding debounce is not required in my use case.

Sorry it’s closed source project.

But you are still thinking that I am controlling towers through a localscript and not a server. I am using script, it runs on a server.

1 Like

Gosh Daw,

The reason you show your code is to make it easier for someone to help you; fresh eyes on your code may see a silly bug which you are blind to; and also because helping someone is its own reward: Tutoring a person in your class at school is always going to increase one’s own grasp of the subject (You can study the ways which other people learn, what you have learned).

Helping someone is almost always a selfish act.

And, sorry, I still can’t see your problem: A visual effect is going to be either local = no need for a remote, or global = no need for a remote. BUT, my project doesn’t use the Player’s avatar, so I could be blind to your problem…

But, another stab in the dark: Remember that remotes from the client, always automatically send, Player, as the “unseen” first argument…

Maybe you can lessen the number of remotes from the Server by sending an entire List of objects in the call, rather than one by one…

Good Luck