Skip to main content
When your script unloads, the following are cleaned up for you:
  • Connections you made with api.utility.connect.
  • Connections you made with any api.bind.on*, api.legitbot.on*, api.ragebot.on*, api.client.on*, api.players.on*, or api.game.on* signal.
  • Controls you added (AddToggle, AddColorpicker, …) and their saved values.
  • Overrides from OverrideValue.
  • Filters, gates, aim transforms, and force-targets from api.legitbot.
  • Filters, gates, strafe overrides, and force-targets from api.ragebot.
  • Your script’s tab.

Manual cleanup

The one thing you should clean up yourself is anything you connected to a control (OnChange, OnUpdate, OnClick, Watch, …). Those return a function you call to stop listening, so hand it to api.onUnload:
local stop = handle:OnUpdate(applyColor)
api.onUnload(stop)
If you keep a handle across async work, check Exists before using it.