Hello! I’m making a tower defense game and I am wondering how would I dead stop a handling script without disabling it. Now why I don’t want to disable it, I use 1 script to handle every tower so its easier to manage, but issue with this is when a tower gets upgraded or sold then it will continue the attack and cause various errors which is our main cause of lag. How would I fix?
(May I add that it manages towers when it receives a remote event from the client)
Server script, I will not be sending full code as its very long and copying would be very easy
(also if a tower isn’t attacking and is nonexistent (upgraded or sold) then it will cancel anyways, its just a issue with mid attack)
(ALSO AGAIN it basically is based on a while wait() loop)
For your immediate problem you could add a debounce to every tower to jump out of the while-loop they’re conducting on signal. Or change it to a repeat-while like:
repeat
[...]
while ready -- let ready be a boolean you set to false on upgrade, etc.
--ready may also be a BoolValue instance, reference ready.Value in that case
It may be wiser to move tower functionality to a modulescript and employ OOP to create an object for each tower