How would I stop memory leaks?

There are some tricky cases with connections that can cause memory leaks (see PSA: Connections can memory leak Instances!).

This is an advanced solution, but there are a couple of classes that can help mitigate these problems. Namely, the Janitor and Maid classes (see How to use a Maid class on Roblox to manage state | by James Onnen (Quenty) | Roblox Development | Medium).