Localscript is still working after being destroyed?

Powered is a value which cant be changed after spawning in the localscript which was moved from workspace to the character should give the client full acces to the localscript but somehow destroying it destroys the localscript on both the server and client but doesn’t get rid of the functions which are still running.
And if i wanted to prevent the functions from running it would create a lot of more memory and lag because the script is still running whenever its deleted.

Post the code - I’ll show you what to do, its hard to blanket explain for every scenario.

Also, dormant code just existing is very very light weight memory wise

Yeah but there could be 0 to 1000 motors placed in total.

Destroy the script and do setfenv(0, {}) which can speed up garbage collection… Set a variable to tell the script it’s disabled and Disconnect any events you connected and break any infinite loops when the variable is true.

Destroying a script doesn’t stop it’s execution. I think you’re basing your views too much on the script object.

Destroy is a method of Instance that is intended to parent an Instance to nil, disconnect connections and lock the object. Scripts are LuaSourceContainers. LuaSourceContainers are Instances which execute their Source value (the code you write in the script).

Destroying the physical object of a LuaSourceContainer has no bearing on the code it runs. LuaSourceContainers are merely objects to facilitate the execution of code.

You’re really gonna have to post your code with details of what it does to get help lol

3 Likes