As a newer scripter, I ran into some very bad memory leak issues a month or two ago and do everything I can to prevent them but I feel that maybe I am doing too much. For example here is the start of one the the scripts that allows the character to do a heavy attack :
game.Players.PlayerAdded:Connect(function(Player)
local PlayerConnections = {
CharacterConnection = nil,
DeathConnection = nil
}
local CharacterConnections = {
CombatEvent = nil
}
PlayerConnections.CharacterConnection = Player.CharacterAdded:Connect(function(character)
end)
end)
That is not my full code but I basically disconnect everything I can when the player dies or leaves the game. If they leave I disconnect that .CharacterAdded event and if they die I disconnect the CombatEvent within the .CharacterAdded event. Not sure if this is necessary as I have seen a lot of controversy about if a event should be disconnected once the instance it refers to no longer exists.