if I disable a script I know that the events will not be detected and also when it is activated it restarts, but I have doubts that may seem silly, when I disable it, it cleans the memory occupied by the local script, the functions, tables, all of this.
Scripts don’t stop running when they’re Destroyed or Disabled, and so any objects they’re keeping alive won’t be cleaned up just from doing that. For example:
script.Disabled = true
print("Ayyy")
local a = Instance.new("Part", game.Workspace)
a.AncestryChanged:Connect(function()
print("Died")
end)
while wait(1) do
print("ping")
wait(1)
print("pong")
end
If you do this in a place with no base plate, the newly created part falls to it’s death and the script prints “Died”. From this you can see that the connection object sticks around after the script is Disabled, and also that the script keeps running in general.
In general, I would refrain from using destroying or disabling scripts to control logic.